在AX中解析多层的json信息
Alfred_CN 人气:0 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"));
}
}
加载全部内容