在AX中解析多层的json信息
程序员文章站
2022-04-29 16:21:54
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);
'{"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"));
}
}
上一篇: 怎样泡玫瑰花茶,喝玫瑰花茶有什么好处
下一篇: 榴莲披萨好吃吗,你知道怎么制作吗