Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

There are a lot of example in Stackoverflow to show howto parse JSON. But no example worked for me and I guess I have a general issue, which I do not understand:

I get an error at following statement:

JSONObject obj2 = new JSONObject("{interests : [{interestKey:Dogs}, {interestKey:Cats}]}");

Exception:

Exception in thread "main" java.lang.RuntimeException: Stub!
    at org.json.JSONObject.<init>(JSONObject.java:7)
    at JSONTest.main(JSONTest.java:44)

I am using Java 1.7 and the library org.json

I tried examples like: example 1 example 2

What could be the reason ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
431 views
Welcome To Ask or Share your Answers For Others

1 Answer

The problem is that you have android.jar in your project's classpath. If you are writing an Android app, you must run it in an emulator or on an actual device. (This also means you will need an Activity instead of main() and also learn the basic building blocks of an Android app.) Otherwise, you should remove anything related to Android from your project's classpath and use the standard Java SDK instead. The easiest way to clean things up is to create a brand-new Java (non-Android) project.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...