Skip to content

Unexcpected result when converting a xml string value starting with '0E'  #265

Description

@janvandeklok

Hello people,

I am using your brilliant library org.json for converting xml to json.

I noticed that the 20160212 20160807 versions have a serious bug. When I convert this xml:
<OLTT_TUE_CURSUS_R><Cursus>0E010</Cursus><Cursus>0E050</Cursus><Cursus>0F010</Cursus><Cursus>aaaaaaa</Cursus></OLTT_TUE_CURSUS_R>

With the 20160807 version, I get this result : {"OLTT_TUE_CURSUS_R":{"Cursus":[0,0,"0F010","aaaaaaa"]}}

With the 20160212 version, I get this result : {"OLTT_TUE_CURSUS_R":{"Cursus":[0,0,"0F010","aaaaaaa"]}}
With the 20151123 version, I get this result : {"OLTT_TUE_CURSUS_R":{"Cursus":["0E010","0E050","0F010","aaaaaaa"]}}

It looks like that the 2016 versions interprets Strings that start with ‘0E’ as numeric values with exponents.

I would like to use the 2016 version since it supports OSGI. Is there a work around (some config setting or so) to handle this problem or do I have to wait for a software fix?

Here is the test code :

   String expectedResult="{\"OLTT_TUE_CURSUS_R\":{\"Cursus\":[\"0E010\",\"0E050\",\"0F010\",\"aaaaaaa\"]}}";
   String xml =  "<OLTT_TUE_CURSUS_R><Cursus>0E010</Cursus><Cursus>0E050</Cursus><Cursus>0F010</Cursus><Cursus>aaaaaaa</Cursus></OLTT_TUE_CURSUS_R> ";
 assertEquals(expectedResult, XML.toJSONObject(xml).toString());

Kind regards,

Jan van de Klok
CACI bv, Claudius Prinsenlaan 146 A, 4818 CP Breda, The Netherlands
T: +31 (0)88 6543429 | M: +31 (0) 655177129 | W: http://www.caci.nl

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions