Skip to content

XML.toJSONObject interprets certain strings as infinite numbers #27

Closed
@bachp

Description

@bachp

Take the following XML snippet as an example.

<?xml version="1.0" encoding="UTF-8"?>
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.6.0">
  <playlists>
    <playlist id="476c65652e6d3375" name="Mood"/>
    <playlist id="50617274792e78737066" name="Party"/>
  </playlists>
</subsonic-response>

the playlist elements have id's that are hexadecimal strings.

in <playlist id="50617274792e78737066" name="Party"/> the id can also be interpreted as an exponential number. This makes the conversion of this snippet fail with the message: org.json.JSONException: JSON does not allow non-finite numbers

I don't know if there is a way to tell the difference between a number and a string from XML but I think the problem could be avoided if instead of throwing an exception the implementation interprets the infinite number as a string in any case.

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