简体   繁体   中英

JSONParser showing error in android app

im trying to make app that can communicate with mysql (localhost) Only problem is Eclipse is showing JSONParser Error After trying to find solution for error i found this Tutorial jackson library tho http://jackson.codehaus.org/

i could not found any solution after 2 days digging into android code

JSONParser jParser = new JSONParser();

ERROR:  Multiple markers at this line
- JSONParser cannot be resolved 
 to a type
- JSONParser cannot be resolved 
 to a type 

and this line of code has same error showing

JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);

Please help me so i can continue my app help will highly appreciate! thanks

If you need to parse a JSON string, you do not need to use any JSONParser class. The JSONObject itself can be used for parsing JSON.

Pass the JSON string to a new JSON object as following:

JSONObject responseObject = new JSONObject(response); //response is the JSON string that you get as response
String name = responseObject.get("name");

Similarly you can get the values directly from the responseObject itself. No need to use any third party libraries. You can find a very good documentation here .

EDIT:

I prefer Android Asynchronous Http Client for making web requests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM