Ashu Kumar
Ashu Kumar

Reputation: 832

JSONParser showing error in android app

i m 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

Upvotes: 0

Views: 4559

Answers (1)

Harikrishnan
Harikrishnan

Reputation: 8063

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.

Upvotes: 4

Related Questions