You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XML.toJSONObject() crashes if CDATA is part of XML #287
This looks like another classpath issue. Method end()Z (end method that returns boolean) is defined in the JSONTokener class, which XMLTokener extends.
@AppWerft , are you sure you've included all the classes in the json-java project at runtime? Also, where did you get your copy from?
The latest JSON-Java code is able to parse the sample XML in the StackOverflow page, with CDATA included. Was also able to execute successfully using the following Maven Central Repository releases:
20160810
20160807
20160212
20151123
20150729
20141113
20140107
20131018
Earlier than that, the parser starts throwing exceptions, but not from the CDATA. Recommend that you try a later build and let us know if the problem persists: http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.json%22%20AND%20a%3A%22json%22
Thank you. Now I have used the newest version.
At runtime:
[ERROR] : AsyncHttpRH: User-space exception detected!
[ERROR] : AsyncHttpRH: java.lang.NoSuchMethodError: No static method stringToValue(Ljava/lang/String;)Ljava/lang/Object; in class Lorg/json/JSONObject; or its super classes (declaration of 'org.json.JSONObject' appears in /system/framework/core-libart.jar)
My thoughts:
in buildpath is android.jar from sdk23 too (on start of list). This version don't know this method 'stringToValue()'. How can I solve? I build with ant.
Unless @johnjaylward has additional comments, suggest you send us enough information about your devekopment environment, such that we can try to recreate the problem.
@AppWerft, it appears to be a configuration issue with how you are building your application. If you can post your ant build file that would be a helpful start.
My problem is: the result of XML.toJSONObject() generates a construct of JSONObject/JSONArray. This parts are from your lib and not from org.json. I'm working with Appcelerator Titanium and the framework tries to convert to javascript layer and aspects that this is from org.json. Therefore I run in an error. If your lib would extends the original org.json (and not "overwrite" with same package name/classnames) then it would works. Currently I return a stringify version of result and parse on JS layer.
You make a new class JSONObjectPlus. This class extends JSONObject. In this case you need i.e only to add StringtoValue() to this class and you avoid evil copy processes.
Refactoring the JSON-Java org.json package name is not an option at this time. No objection to other reasonable actions to help the Android devs, which can be posted here. This issue will be left open for a few days in case of comment. The Wiki will be updated with a section on the issues facing Android devs.
If someone wants to start a project that contains only the minimal changes to JSON-Java needed for Android support, links can be added from this Readme and Wiki. Otherwise, please post here of any changes you think are necessary.
I don't think we have a 3rd party solution that we can point Android devs to (but correct me if I am wrong). Ideally, this this problem should be fixed in the Android project. Does anyone want to drive this? Otherwise, is there anything we can do to make the XML code Android friendly, without affecting our own users?
@stleary no, I don't think so. I don't actually know why it's included by the app, I was just called in to troubleshoot the weird error. It looked to me like a really really old version of your library was embedded inside the Easy JSON jar. Nothing you can really do to avoid it, but at least this ticket can document the possible reasons for this error.
Activity
stleary commentedon Sep 21, 2016
Thanks! Will investigate as soon as possible.
johnjaylward commentedon Sep 21, 2016
This looks like another classpath issue. Method end()Z (end method that returns boolean) is defined in the JSONTokener class, which XMLTokener extends.
@AppWerft , are you sure you've included all the classes in the json-java project at runtime? Also, where did you get your copy from?
stleary commentedon Sep 22, 2016
The latest JSON-Java code is able to parse the sample XML in the StackOverflow page, with CDATA included. Was also able to execute successfully using the following Maven Central Repository releases:
20160810
20160807
20160212
20151123
20150729
20141113
20140107
20131018
Earlier than that, the parser starts throwing exceptions, but not from the CDATA. Recommend that you try a later build and let us know if the problem persists:
http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.json%22%20AND%20a%3A%22json%22
AppWerft commentedon Sep 22, 2016
Thank you. Now I have used the newest version.
At runtime:
My thoughts:
in buildpath is android.jar from sdk23 too (on start of list). This version don't know this method 'stringToValue()'. How can I solve? I build with ant.
AppWerft commentedon Sep 22, 2016
Now I have refactored your package to org.json.jsonjava and all is fine. Is there a reason to use the same package name?
stleary commentedon Sep 22, 2016
Unless @johnjaylward has additional comments, suggest you send us enough information about your devekopment environment, such that we can try to recreate the problem.
johnjaylward commentedon Sep 22, 2016
@AppWerft, it appears to be a configuration issue with how you are building your application. If you can post your ant build file that would be a helpful start.
AppWerft commentedon Sep 23, 2016
My problem is: the result of XML.toJSONObject() generates a construct of JSONObject/JSONArray. This parts are from your lib and not from org.json. I'm working with Appcelerator Titanium and the framework tries to convert to javascript layer and aspects that this is from org.json. Therefore I run in an error. If your lib would extends the original org.json (and not "overwrite" with same package name/classnames) then it would works. Currently I return a stringify version of result and parse on JS layer.
AppWerft commentedon Sep 23, 2016
One question: you method toMap(): why the method doesn't work recursively? Like this: https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/kroll/KrollDict.java#L48-L70
stleary commentedon Sep 23, 2016
No objection if you want to propose a pull request to enhance toMap().
AppWerft commentedon Sep 23, 2016
Hi, I have modified and now it runs.
2, I have rewrite toMap() https://github.com/AppWerft/Ti.RemoteXML/blob/master/android/src/de/appwerft/remotexml/JSON.java
AppWerft commentedon Sep 23, 2016
Version with new conflictless packagename
johnjaylward commentedon Sep 23, 2016
@AppWerft can you post a non-compressed version?
johnjaylward commentedon Sep 23, 2016
@AppWerft it looks like you are trying to use 2 different versions of the JsonJava code, one of which you repackaged as or.json.jsonjava
I'm not able to understand why you would do this. Is there some reason you need to include 2 different versions?
AppWerft commentedon Sep 23, 2016
here is it
Am 23/09/16 um 20:00 schrieb johnjaylward:
Dipl.-Ing. Rainer Schleevoigt
Certified TYPO3 Integrator
Certified Titanium App Developer
22303 Hamburg
℡ 040 60812460
|Ust-ID: DE239491976|||||||
11 remaining items
AppWerft commentedon Sep 24, 2016
You make a new class JSONObjectPlus. This class extends JSONObject. In this case you need i.e only to add StringtoValue() to this class and you avoid evil copy processes.
AppWerft commentedon Sep 24, 2016
stleary commentedon Sep 24, 2016
Refactoring the JSON-Java org.json package name is not an option at this time. No objection to other reasonable actions to help the Android devs, which can be posted here. This issue will be left open for a few days in case of comment. The Wiki will be updated with a section on the issues facing Android devs.
stleary commentedon Sep 25, 2016
https://github.com/stleary/JSON-java/wiki/JSON-Java-for-Android-developers
The Wiki page is currently open for anyone to make changes, if you want to add new information or edit what is already there.
stleary commentedon Sep 28, 2016
If someone wants to start a project that contains only the minimal changes to JSON-Java needed for Android support, links can be added from this Readme and Wiki. Otherwise, please post here of any changes you think are necessary.
AppWerft commentedon Sep 28, 2016
I will do. I have built a special exporter. It works fine. Currently I'm testing against: all links inside http://www.openarchives.org/pmh/registry/ListFriends
stleary commentedon Oct 15, 2016
Any updates on your exporter, @AppWerft?
AppWerft commentedon Oct 15, 2016
Yes, I'm using a recursivly working cloner. https://github.com/AppWerft/Ti.OAI-PMH/blob/master/android/src/de/appwerft/oaipmh/KrollHelper.java
stleary commentedon Nov 19, 2016
I don't think we have a 3rd party solution that we can point Android devs to (but correct me if I am wrong). Ideally, this this problem should be fixed in the Android project. Does anyone want to drive this? Otherwise, is there anything we can do to make the XML code Android friendly, without affecting our own users?
quelgar commentedon Dec 22, 2016
FYI I hit this due to a library called Easy JSON being on the classpath. It has its own version of
org.json.JSONTokener.stleary commentedon Dec 23, 2016
@quelgar does EasyJSON have some functionality that is missing from this project?
quelgar commentedon Dec 24, 2016
@stleary no, I don't think so. I don't actually know why it's included by the app, I was just called in to troubleshoot the weird error. It looked to me like a really really old version of your library was embedded inside the Easy JSON jar. Nothing you can really do to avoid it, but at least this ticket can document the possible reasons for this error.
johnjaylward commentedon Jun 21, 2017
see #350
stleary commentedon Jan 13, 2018
This issue has been addressed to the extent that we can from this side. For more information please see the wiki page: https://github.com/stleary/JSON-java/wiki/JSON-Java-for-Android-developers