Menu

#28 XML to JSON conversion fails sometimes

open
nobody
None
5
2012-09-06
2011-10-11
Pascal
No

Under certain circumstances the conversion from XML to JSON fails because of a bug in the JSON-Java library bundled with subsonic.

Take the following playlist XML snippet as an example.

<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.

This problem should be fixed in newer versions of JSON-Java (https://github.com/douglascrockford/JSON-java)

Discussion

Anonymous
Anonymous

Add attachments
Cancel