欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

在AX中解析多层的json信息

程序员文章站 2022-08-05 07:50:08
str jsonstr ='{"FieldValues":[{"FieldName":"Field1","FieldValue":"Rec1Field1Value"},'+ '{"FieldName":"Field2","FieldValue":"Rec1Field2Value"}]}'; Map ......
    str jsonstr ='{"fieldvalues":[{"fieldname":"field1","fieldvalue":"rec1field1value"},'+
    '{"fieldname":"field2","fieldvalue":"rec1field2value"}]}';
    map     jsonmap, linemap;
    container   linecon;
    container   itemscon;
    listenumerator          listenumerator;
    mapenumerator           mapenumerator;
    list                    linelist;
    ;
    jsonmap = retailcommonwebapi::getmapfromjsonstring(jsonstr);
    if (jsonmap.exists("fieldvalues"))
    {
        itemscon = jsonmap.lookup("fieldvalues");
        linelist = list::create(itemscon);
        listenumerator = linelist.getenumerator();
        while (listenumerator.movenext())
        {
            linecon = listenumerator.current();
            linemap = map::create(linecon);
            info(linemap.lookup("fieldname"));
            info(linemap.lookup("fieldvalue"));
        }
    }