Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
3 replies Latest Post - ‏2013-04-18T12:46:46Z by mones
SystemAdmin
SystemAdmin
1493 Posts
ACCEPTED ANSWER

Pinned topic XML to JSON conversion in WebSphere Experince factory using builder.

‏2012-10-08T09:23:11Z |
I have few fields in schema which are int type. When i tried converting this XML(Derived form this schema) to JSON using the builder "XML to json convertor" ,i always get those fields as strings(Inside the double quotes) and not as integers(Not inside the double quotes).
That means any XML given to this builder is converted to String data in JSON.

Is there any way i can specify the data type in json or in IXML api or in builder ?
Updated on 2012-10-17T11:43:26Z at 2012-10-17T11:43:26Z by SystemAdmin
  • kevintap
    kevintap
    111 Posts
    ACCEPTED ANSWER

    Re: XML to JSON conversion in WebSphere Experince factory using builder.

    ‏2012-10-08T20:19:05Z  in response to SystemAdmin
    Unfortunately, there isn't an easy way to specify how a value like an integer should be converted when converting to JSON. The code that WEF uses will always wrap the values in double quotes as strings.

    I have entered an enhancement request for a future product release to help address this and other similar enhancements in the XML to JSON converter.
    • SystemAdmin
      SystemAdmin
      1493 Posts
      ACCEPTED ANSWER

      Re: XML to JSON conversion in WebSphere Experince factory using builder.

      ‏2012-10-17T11:43:26Z  in response to kevintap
      Hi Kevin,
      Thanks for replying and taking the issue to the further enahancment.But the issue is ::
      We want to achieve numerical sorting in Filtering select . Since filtering select always reads json data ,it applies the alphanumeric sorting or numerical sorting on the basis of data type of JSON data.
      Having said that Filtering select always sort the data as string ( alphanumeric ).

      I have achieved numerical sorting in filtering select by creating our own DOJO data Store and then change the JSON data from String to Int. Please find the attachment .
      BUT this approach is not align with our conventions of project and it is breaking the re-usability too, We are using the concept of shared library(RDD) and DFS(Data Field setting) builder .

      Is there any way we can incorporate this three builders in a XML (RDD) file 1.XML to JSON convertor 2. DOJO data store 3. DOJO filtering select . Or in other words can we make a data definition in a xml which uses these three builders .Later that Xml file will be read by DFS,So that other developers just need to select a field type and lookup (xml-data) in DFS.

      Feel free to ask more question if you need more clarifications.
      • mones
        mones
        1 Post
        ACCEPTED ANSWER

        Re: XML to JSON conversion in WebSphere Experince factory using builder.

        ‏2013-04-18T12:46:46Z  in response to SystemAdmin

        You can use a custom class to traverse your IXml and generate the JSON you like with the help of the google-gson library.

        We've solved a similar issue (not datatype but structure related) with this approach and it's relatively easy to do. The resulting class is fully reusable (unless you want a different format, of course :-)