Topic
  • 2 replies
  • Latest Post - ‏2013-03-12T17:36:54Z by ansmyke
ansmyke
ansmyke
98 Posts

Pinned topic JSON response formatting in firmware 5.0.0.3

‏2013-03-07T01:06:02Z |
In we are using firmware version 5.0.0.3 and 4.0.1.4 in our different envirnoments.

We have noticed few issues with firmware version 5.0.0.3 regarding JSON processing(formatting related). The below is the detail about issue:

1)

In firmware 4.0.1.1
A.
<json:object name="AcknowledgementStatus">
<json:string name="StatusTypeCode">
SUCCESS
</json:string>
</json:object>

B.
<json:object name="AcknowledgementStatus">
<json:string name="StatusTypeCode">SUCCESS</json:string>
</json:object>
The above two statement produce same result when JSONX2JSON.xsl transformation is applied and output is printed in the rest client which is;
{ "StatusTypeCode":"SUCCESS" }

In firmware 5.0.0.3:

The first statement breeds
{ "StatusTypeCode":"\n \t\t\t\t\t\t\t\t\t SUCCESS\t\t\t\t\t\t\t\t\t " }

2) In firmware version 5.0.0.3:

special characters are escaped

Also if there is any hardcoded url in the stylesheet
<json:string name ="url"> http://xyz.com </json:string>
Will breed { "url”:”http:\/\/xyz.com”}
I am not sure if the above outcomes are result of firmware enhancement or is it a firmware bug ? I have checked firmware release notes but couldn’t find anything helpful on this.
Thanks,
Mayank
Updated on 2013-03-12T17:36:54Z at 2013-03-12T17:36:54Z by ansmyke
  • HermannSW
    HermannSW
    7080 Posts

    Re: JSON response formatting in firmware 5.0.0.3

    ‏2013-03-07T08:39:09Z  
    5.0.0.3 is October 2012 fixpack, which corresponds to 4.0.1.13.

    I did lookup "store:///jsonx2json.xsl" on both firmwares.
    That file was never changed on 5.0.0 firmware until now.
    And the only change on 4.0.1 firmware was by this 4.0.1.6 firmware APAR IC79035:
    http://www-01.ibm.com/support/docview.wss?uid=swg1IC79035

    Lets focus on your second problem for now.
    nightcrawler version is "XI50.5.0.0.3".
    As you can see the output returned by my box is identical to yours.
    I attached the jsonx input file I crafted based on the data you provided.
    
    $ coproc2 jsonx2json.xsl ansmyke.2.jsonx http:
    //nightcrawler:2223 ; echo 
    { 
    "url":
    " http:\/\/xyz.com " 
    } $ $ cat ansmyke.2.jsonx <json:object xsi:schemaLocation=
    "http://www.datapower.com/schemas/json jsonx.xsd" xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance" xmlns:json=
    "http://www.ibm.com/xmlns/prod/2009/jsonx" > <json:string name =
    "url"> http:
    //xyz.com </json:string> </json:object> $
    


    Both slash characters '/' get escaped as '\/', which is OK according the JSON spec:
    http://tools.ietf.org/html/rfc4627#section-2.5
    2.5. Strings
    The representation of strings is similar to conventions used in the C
    family of programming languages. A string begins and ends with
    quotation marks. All Unicode characters may be placed within the
    quotation marks except for the characters that must be escaped:
    quotation mark, reverse solidus, and the control characters (U+0000
    through U+001F).

    Any character may be escaped. If the character is in the Basic
    ...

    Any system not able to deal with escaped slashes is not compliant to JSON spec.
    Since this is existing behaviour and correct according the spec, there is no bug.
    You may raise an enhancement request on this, though:
    http://www.ibm.com/developerworks/rfe/

     
    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>
  • ansmyke
    ansmyke
    98 Posts

    Re: JSON response formatting in firmware 5.0.0.3

    ‏2013-03-12T17:36:54Z  
    • HermannSW
    • ‏2013-03-07T08:39:09Z
    5.0.0.3 is October 2012 fixpack, which corresponds to 4.0.1.13.

    I did lookup "store:///jsonx2json.xsl" on both firmwares.
    That file was never changed on 5.0.0 firmware until now.
    And the only change on 4.0.1 firmware was by this 4.0.1.6 firmware APAR IC79035:
    http://www-01.ibm.com/support/docview.wss?uid=swg1IC79035

    Lets focus on your second problem for now.
    nightcrawler version is "XI50.5.0.0.3".
    As you can see the output returned by my box is identical to yours.
    I attached the jsonx input file I crafted based on the data you provided.
    <pre class="jive-pre"> $ coproc2 jsonx2json.xsl ansmyke.2.jsonx http: //nightcrawler:2223 ; echo { "url": " http:\/\/xyz.com " } $ $ cat ansmyke.2.jsonx <json:object xsi:schemaLocation= "http://www.datapower.com/schemas/json jsonx.xsd" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:json= "http://www.ibm.com/xmlns/prod/2009/jsonx" > <json:string name = "url"> http: //xyz.com </json:string> </json:object> $ </pre>

    Both slash characters '/' get escaped as '\/', which is OK according the JSON spec:
    http://tools.ietf.org/html/rfc4627#section-2.5
    2.5. Strings
    The representation of strings is similar to conventions used in the C
    family of programming languages. A string begins and ends with
    quotation marks. All Unicode characters may be placed within the
    quotation marks except for the characters that must be escaped:
    quotation mark, reverse solidus, and the control characters (U+0000
    through U+001F).

    Any character may be escaped. If the character is in the Basic
    ...

    Any system not able to deal with escaped slashes is not compliant to JSON spec.
    Since this is existing behaviour and correct according the spec, there is no bug.
    You may raise an enhancement request on this, though:
    http://www.ibm.com/developerworks/rfe/

     
    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>
    Thanks Herman, will do.