user671005
user671005

Reputation: 215

Getting Response in the form of json on logcat

{
    "Generalinfor": {
        "type": "Response",
        "name": "abcde",
        "ver": "3.0.0" 
    },
    "Login": {
        "errorCode": "001",
        "errorMsg": "Login Failed - Missing of Password",
        "userID": "0",
        "versionAvail": "",
        "versionDownloadMsg": "can't login " 
    } 
} 

I am getting response in json format on logcat from my web server.Now i wanted to convert it into string and to displayed this image on emulator. How can I accomplish this?

Please guide me with any tips or sample code possible.

Upvotes: 0

Views: 1044

Answers (1)

Blundell
Blundell

Reputation: 76458

import org.json.JSONObject;

JSONObject jObject = new JSONObject(yourJsonString);

http://www.json.org/javadoc/org/json/JSONObject.html

String type = (String) jObject.get("type"); // would return your type 'Response'

http://www.json.org/javadoc/org/json/JSONObject.html#get(java.lang.String)

etc...

Upvotes: 2

Related Questions