在AX中解析多层的json信息

    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"));
        }
    }
posted @ 2020-03-10 14:39  Alfred_CN  阅读(312)  评论(0编辑  收藏  举报