![]() |
#1 |
Участник
|
palleagermark: Testing JSON from AX 2012
Источник: http://www.agermark.com/2015/01/test...m-ax-2012.html
============== I wanted to see how JSON could be consumed from AX, and found this great article from Jonathan. Then I needed something to test with and found the site jsontest.com. And so, here are two examples. The first example just returns your IP address: X++: static void JSONTestIP(Args _args) { RetailWebRequest request; RetailWebResponse response; str rawResponse; Map responseData; str responseValue; RetailCommonWebAPI webApi = RetailCommonWebAPI::construct(); request = RetailWebRequest::newUrl("http://ip.jsontest.com"); response = webApi.getResponse(request); rawResponse = response.parmData(); responseData = RetailCommonWebAPI::getMapFromJsonString(rawResponse); responseValue = responseData.lookup("ip"); info(strFmt("Element name: %1", responseValue)); } X++: static void JSONTestKeyValue(Args _args) { RetailWebRequest request; RetailWebResponse response; str rawResponse; Map responseData; str responseValue; RetailCommonWebAPI webApi = RetailCommonWebAPI::construct(); request = RetailWebRequest::newUrl("http://echo.jsontest.com/Agermark/Palle/Kent/Clark"); response = webApi.getResponse(request); rawResponse = response.parmData(); responseData = RetailCommonWebAPI::getMapFromJsonString(rawResponse); responseValue = responseData.lookup("Kent"); info(strFmt("Element name: %1", responseValue)); }
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. Последний раз редактировалось mazzy; 12.01.2015 в 21:33. |
|
|
|