0
{
    "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 " 
    } 
} 

我从我的网络服务器收到json格式的响应。现在logcat我想将其转换为字符串并在模拟器上显示此图像。我怎样才能做到这一点?

请指导我提供任何提示或示例代码。

4

1 回答 1

2
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...

于 2011-03-31T14:20:24.450 回答