While writing some code for the Exchange Rate Provider class, I ran across an issue where some exchange rate provider APIs only gave JSON output instead of XML. I found very little in Dynamics AX that would let me deserialize JSON. The only alternative was to manually parse the data based on the structure provided at the time.
I didn't like that approach. Manually parsing data like that can be a nightmare. The only tools I know of in Dynamics AX are the XML tools. With that in mind, I decided to write a JSON to XML converter.
classdeclaration
loadFromFile
convert2xml
convert
getTag
4 comments:
Hi,
Do you know how to convert from xml to json using x++ code?
Regards
Melvin
Hello Joe, very lot thank you!
Thank you
Regards
amoxto
Thanks a lot for the script,
but probably it contains error, maybe it must be like this:
for(i=1;i<=strLen(_str);i++)
{
if (subStr(_str,i,1) == '"')
{
inquote= !inquote;
}
if (char2num(_str,i) <= #SPACE && !inquote)
{
continue;
}
tmpStr = tmpStr + subStr(_str,i,1);
}
return tmpStr;
}
Otherwise, it cust all SPACE characters from string including those in quotes.
Post a Comment