Author |
Message
|
arunkumar1989 |
Posted: Wed Apr 09, 2014 3:28 am Post subject: How to Convert JSONX to JSON? |
|
|
 Voyager
Joined: 21 Nov 2012 Posts: 98 Location: Chennai
|
Hi All,
This is my JSONX Message
-------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<json:object name="person"
xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd"
xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<json:object name="details">
<json:string name="city">Cleveland</json:string>
<json:string name="state">OH</json:string>
<json:string name="street">3661 Lincoln Avenue</json:string>
<json:number name="zipcode">44111</json:number>
</json:object>
<json:object name="name">
<json:string name="firstname">Sarah</json:string>
<json:string name="lastname">Chan</json:string>
<json:string name="title">Mrs</json:string>
</json:object>
</json:object>
How to Convert this to JSON? _________________ Being in a crowd when you are alone is ignorance. Enlightenment is being alone in a crowd; a feeling of oneness in a crowd. |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Apr 09, 2014 3:39 am Post subject: Re: How to Convert JSONX to JSON? |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
This is (just) xml
Answer:
Code: |
CALL CopyMessageHeaders();
SET OutputRoot.JSON = InputRoot.XMLNSC; |
On the input node configure XMLNSC
Minor correction may (have to be) apply(/applied) _________________ Just use REFERENCEs
Last edited by mqsiuser on Wed Apr 09, 2014 3:40 am; edited 1 time in total |
|
Back to top |
|
 |
sumit |
Posted: Wed Apr 09, 2014 3:39 am Post subject: |
|
|
Partisan
Joined: 19 Jan 2006 Posts: 398
|
As far as I know, DataPower does that for you. _________________ Regards
Sumit |
|
Back to top |
|
 |
sumit |
Posted: Wed Apr 09, 2014 4:02 am Post subject: Re: How to Convert JSONX to JSON? |
|
|
Partisan
Joined: 19 Jan 2006 Posts: 398
|
mqsiuser wrote: |
This is (just) xml
Answer:
Code: |
CALL CopyMessageHeaders();
SET OutputRoot.JSON = InputRoot.XMLNSC; |
|
I suspect this kind of approach will cause problem when input XML has repeating tags, which requires 'Array of objects' representation in out going JSON message. _________________ Regards
Sumit |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Apr 09, 2014 4:12 am Post subject: Re: How to Convert JSONX to JSON? |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
My post is a total over-simplification, yes
You'll likely have to write some (custom) (transformation) code _________________ Just use REFERENCEs |
|
Back to top |
|
 |
arunkumar1989 |
Posted: Wed Apr 09, 2014 5:33 am Post subject: |
|
|
 Voyager
Joined: 21 Nov 2012 Posts: 98 Location: Chennai
|
Sorry to all, it can be easily done in Message Broker, but i need to do this in data power, so i need xslt , Please anybody _________________ Being in a crowd when you are alone is ignorance. Enlightenment is being alone in a crowd; a feeling of oneness in a crowd. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Apr 09, 2014 5:45 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Moved to DataPower section _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Esa |
Posted: Thu Apr 10, 2014 3:03 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
arunkumar1989 wrote: |
Sorry to all, it can be easily done in Message Broker, but i need to do this in data power, so i need xslt , Please anybody |
Have you read what the InfoCenter says here? |
|
Back to top |
|
 |
arunkumar1989 |
Posted: Mon Apr 14, 2014 11:52 pm Post subject: |
|
|
 Voyager
Joined: 21 Nov 2012 Posts: 98 Location: Chennai
|
Got the Solution...!!!
In DataPower store location they have file called jsonxtojson.xsl
store:///jsonxtojson.xsl
We do not want to write XSLT for this conversion.
Thanks to all for your replies. _________________ Being in a crowd when you are alone is ignorance. Enlightenment is being alone in a crowd; a feeling of oneness in a crowd. |
|
Back to top |
|
 |
|