Hi,
might this be helpful for somebody?
Because I needed it, I created a small IS package “JsonSupport ” which includes two services:
documentToJSONString (accepts Document or DocumentList as input)
jsonStringToDocument (returns Document or DocumentList depending on the input)
The accompanying “JsonSupportTEST ” folder contains files to test the services in Designer (Service-Runner → “Load and Replace…”).
Internally, it uses the org.json Java package downloaded from [url=http://www.json.org/java/]http://www.json.org/java/[/url] .
On the Mobile Designer side, org.json.me is a good counterpart ([url=https://github.com/upictec/org.json.me/]https://github.com/upictec/org.json.me/[/url] ).
Be aware that this is experimental … good for demos perhaps … but probably is not be the “perfect” implementation. So, expect horrible bugs … poor scaling … and many more bad things
Regards,
Peter
JsonSupport.zip (52.7 KB)
JsonSupportTEST.zip (5.2 KB)
1 Like
system
(system)
February 24, 2012, 11:48pm
2
There is a project on Labcase that provides full JSON support. Please check with Kevin Bouck.
Thanks Christian!
I had overseen the existence of xWmJSON in LabCase.
Regards,
Peter
Chandra6
(Chandra)
May 7, 2012, 7:06pm
4
Hi Peter,
How can I get the xWmJSON from LabCase? Thanks -Chandra
Chandra6
(Chandra)
May 15, 2012, 7:46pm
5
Using JSON API I could convert XML to target format. Below is the snippet placed in java service.
int PRETTY_PRINT_INDENT_FACTOR = 4;
JSONObject xmlJSONObj = null;
String outputJson = “”;
try {
xmlJSONObj = XML.toJSONObject(inputXml);
outputJson = xmlJSONObj.toString(PRETTY_PRINT_INDENT_FACTOR);
} catch (JSONException je) {
System.out.println(je.toString());
}
I’m doing the same :
convert using documentToXMLString
use an home made java service based on json.org to convert the result string to JSon.
But it introduce a limitation : where as having a field name containing space is valid for both wM’s documents and Json, it’s not valid for the intermediate XML …
Only a limitation to know when building flow documents.
The documenttojsonstring is putting quotes around integers. Is there a newer version of this jar or how can i access the labcase code?
Hi,
IS can now handle JSON document in wM 9.5
Refer the below services:
pub.json:documentToJSONString
pub.json:jsonStreamToDocument
pub.json:jsonStringToDocument
For more information refer 9-5-SP1_Integration_Server_Built-In_Services_Reference.pdf
what jar or methods wM IS (9.5 and above) uses for json inbuild services?
IDataJSONCoder - wM JAVA API - Encodes an Integration Server document to JSON and
decodes JSON to an Integration Server document.
Regarding the jars I guess it should be json-lib.jar, java-json.jar
But SAG uses Jackson java libraries for JSON implementation.
What is your requirement here?