在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);
'{"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();
{
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"));
}
}
{
lineCon = listEnumerator.current();
lineMap = Map::create(lineCon);
info(lineMap.lookup("FieldName"));
info(lineMap.lookup("FieldValue"));
}
}