AX中Json转化成表记录
static void JsonToTable(str _json,Common _Common)
{
sysdictTable dictTable;
TableId tableId;
dictfield dictField, tmpdictField;
int fieldsNum, i, fieldId, j, tmpdictFieldid;
Map postsData;
Map lineineMap;
List line;
ListEnumerator lineE;
;
postsData = RetailCommonWebAPI::getMapFromJsonString(_json);
{
sysdictTable dictTable;
TableId tableId;
dictfield dictField, tmpdictField;
int fieldsNum, i, fieldId, j, tmpdictFieldid;
Map postsData;
Map lineineMap;
List line;
ListEnumerator lineE;
;
postsData = RetailCommonWebAPI::getMapFromJsonString(_json);
tableId = _Common.TableId ;
dictTable = new sysDictTable(tableId);
fieldsNum = dictTable.columnCnt();
fieldsNum = dictTable.fieldCntWithoutSys();
line = List::create(postsData.lookup(tableId2name(tableId)));
lineE = line.getEnumerator();
while(lineE.moveNext())
{
lineineMap = Map::create(lineE.current());
for(i=1;i<=fieldsNum;i++)
{
fieldId = dictTable.fieldCnt2Id(i);
dictField = new dictField(tableId,fieldId);
for (j=1; j<=dictField.arraySize(); j++)
{
tmpdictFieldid = fieldId2Ext(fieldId, j);
tmpdictField = new dictField(tableId,tmpdictFieldid);
if (lineineMap.exists(tmpdictField.name()))
{
_common.(tmpdictField.id()) = conPeek(lineineMap.lookup(tmpdictField.name()), 1);
}
}
}
_common.insert();
}
}
{
lineineMap = Map::create(lineE.current());
for(i=1;i<=fieldsNum;i++)
{
fieldId = dictTable.fieldCnt2Id(i);
dictField = new dictField(tableId,fieldId);
for (j=1; j<=dictField.arraySize(); j++)
{
tmpdictFieldid = fieldId2Ext(fieldId, j);
tmpdictField = new dictField(tableId,tmpdictFieldid);
if (lineineMap.exists(tmpdictField.name()))
{
_common.(tmpdictField.id()) = conPeek(lineineMap.lookup(tmpdictField.name()), 1);
}
}
}
_common.insert();
}
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】博客园携手 AI 驱动开发工具商 Chat2DB 推出联合终身会员
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步