str output =//JSON String; output = strRem(output, "["); output = strRem(output, "]"); Map jsonData; jsonData = RetailCommonWebAPI::getMapFromJsonString(output); container Error,Log,LinkIds,currentReponse; ListEnumerator listEnumerator,listenum; MapEnumerator mapEnumerator; mapEnumerator = jsonData.getEnumerator(); int AccNum; int Name; int Phone; int address; str errorTxt; str logTxt; str hasErrorStr; while (mapEnumerator.moveNext()) { switch (mapEnumerator.currentKey()) { case "Error": hasErrorStr = mapEnumerator.currentValue(); break; case "Log": logTxt = mapEnumerator.currentValue(); break; case "CustomerDetails"://json array currentReponse = mapEnumerator.currentValue(); if(currentReponse) { for (int i=1; i <= conlen(currentReponse); i++) { switch(conpeek(currentReponse, i)) { case "AccNum": AccNum = conPeek(currentReponse,i+1); break; case "Name": Name = conPeek(currentReponse,i+1); break; case "Phone": Phone = conPeek(currentReponse,i+1); break; case "address": address = conPeek(currentReponse,i+1); break; } } } break; } }
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
Thursday, January 30, 2025
Parse JSON response using X++ to vairables
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment