stleary / JSON-java

A reference implementation of a JSON package in Java.
http://stleary.github.io/JSON-java/index.html
Other
4.54k stars 2.56k forks source link

Converting invalid XML #311

Closed holubec-petr closed 7 years ago

holubec-petr commented 7 years ago

Hi everyone,

when I call XML.toJSONObject("blah") I got empty JSONObject without any error even if input is not a valid XML.

In my opinion this conversion should throw some parsing error or am I bad?

Thanks, Petr

stleary commented 7 years ago

Agreed, a valid expectation might be to match this thrown exception:

JSONObject jsonObject = new JSONObject("blah");

However, the observed behavior of producing an empty object seems to be a valid design choice as well. I wouldn't want to change the released code just for the sake of being more consistent.

stleary commented 7 years ago

No changes are planned to this code at the present time.