The JSON class parsing error that comes with Android is called!!!

Source: Internet
Author: User

============ Problem Description ============


{"Weatherinfo": {"City": "Beijing", "Cityid": "101010100", "Temp1": "2", "Temp2": "All", "weather": "Small to moderate Rain", "IMG1": " D21.gif "," Img2 ":" N7.gif "," Ptime ":" The " .

This is the JSON string that I need to parse out.

Prompt me after running:

Exception in thread "main" Java.lang.noclassdeffounderror:org/json/jsonobject
At Com.test.TestWeather.main (testweather.java:42)
caused By:java.lang.ClassNotFoundException:org.json.JSONObject

This class could not be found.
But I see these JSON-required classes under the Android.jar package.

I tried to import the required package separately, and then I can parse it correctly, but an error occurred when the Android project compiled to generate the APK file.
The prompt package is conflicting. (These packages are visible in the Android.jar.) So there is an error compiling the package.

Ask the great God to help ~~~~~~~~~~

Appreciate it, ~~~~~~.

============ Solution 1============


Has your project been confused and compiled? So that some of the packets that should not be confused are also confused, resulting in the inability to find a method.

============ Solution 2============


Reference 4 floor crazy1235 's reply:
Quote: Quote 3 floor lilidejing reply:

It is recommended to parse JSON with Gson, which is convenient


Do I need to introduce a jar package?

Need, import Gson.jar package on line, Google offers the

============ Solution 3============


Hello, in the Android project, the Java class file cannot be run directly.
You need to use the simulator debug, I've tried it, and Android comes with Jsonobject to parse this string of JSON strings.

The JSON class parsing error that comes with Android is called!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.