Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 解析有效Json时的JSONException_Java_Android_Json - Fatal编程技术网

Java 解析有效Json时的JSONException

Java 解析有效Json时的JSONException,java,android,json,Java,Android,Json,我尝试解析这个有效的JSON 我使用新的JSONObject(resultString)但我有JSONException 我如何解析他的Json 请帮帮我 谢谢 [{ "id": "8637F7F78C8C1", "from_account_id": "1025630", "to_account_id": "1025635", "transaction_type_id": "15", "transaction_mode_id": "2", "tra

我尝试解析这个有效的JSON

我使用
新的JSONObject(resultString)但我有JSONException

我如何解析他的Json

请帮帮我

谢谢

[{
    "id": "8637F7F78C8C1",
    "from_account_id": "1025630",
    "to_account_id": "1025635",
    "transaction_type_id": "15",
    "transaction_mode_id": "2",
    "transaction_status_id": "1",
    "amount": "1000.00",
    "real_amount": "1000.00",
    "promote_amount": "0.00",
    "from_fix_fee_amount": "0.00",
    "from_percent_fee_amount": "50.00",
    "to_fix_fee_amount": "0.00",
    "to_percent_fee_amount": "0.00",
    "description": "demo",
    "created_on": "2012-07-16 10:04:29",
    "activated_on": "0000-00-00 00:00:00",
    "executed_on": "0000-00-00 00:00:00",
    "verify_transaction_by": "o",
    "from_account_name": "xxxxxxxxxxxx",
    "from_account_email": "xxxxxxx@gmail.com",
    "from_account_phone_no": "xxcxxxxxx",
    "to_account_name": "yyyyyyy",
    "to_account_email": "yyyyy@gmail.com",
    "to_account_phone_no": "yyyyyyyy"
},
{
    "id": "A26BF7F75534B",
    "from_account_id": "1014635",
    "to_account_id": "1054630",
    "transaction_type_id": "5",
    "transaction_mode_id": "2",
    "transaction_status_id": "4",
    "amount": "1000.00",
    "real_amount": "1000.00",
    "promote_amount": "0.00",
    "from_fix_fee_amount": "0.00",
    "from_percent_fee_amount": "0.00",
    "to_fix_fee_amount": "0.00",
    "to_percent_fee_amount": "0.00",
    "description": "",
    "created_on": "2012-07-15 00:52:40",
    "activated_on": "2012-07-15 00:53:19",
    "executed_on": "2012-07-15 00:54:57",
    "verify_transaction_by": "o",
    "from_account_name": "yyyyyy",
    "from_account_email": "yyyyyy@gmail.com",
    "from_account_phone_no": "yyyyyyy",
    "to_account_name": "wwwwwww",
    "to_account_email": "yywywyyy@gmail.com",
    "to_account_phone_no": "yyyyyyyyy"
}]

它是一个
JSONArray
而不是
JSONObject

JSONArray值=新的JSONArray(resultString);
对于(int i=0;i
它是一个
JSONArray
而不是
JSONObject

JSONArray值=新的JSONArray(resultString);
对于(int i=0;i
这不是一个JSON对象——它是一个包含两个对象的JSON数组


使用
newjsonarray(resultString)然后从中获取对象。

这不是一个JSON对象-它是一个包含两个对象的JSON数组


使用
newjsonarray(resultString)首先从中获取对象。

Hi[]表示JSON中的数组,因此在解析之后,尝试将其放入JSONArray中<代码>新建JSONArray(resultString).getJSONObject(int索引)


通过这种方式,您可以获得JSON对象。

Hi[]表示JSON中的数组,因此在解析之后,请尝试将其放入JSONArray中<代码>新建JSONArray(resultString).getJSONObject(int索引)

通过这种方式,您可以获取JSON对象..

,用于解析我使用的JSON

JsonArray数组=jobject.getAsJsonArray(“myarray”)
对于 (JsonElement项:数组){…}

用于解析我使用的JSON

JsonArray数组=jobject.getAsJsonArray(“myarray”)
对于 (JsonElement项:数组){…}


如何解析这个JSONArray使用时如何解析这个JSONArray:newjsonarray(resultString);当我使用时,我有一个jsonexception:newjsonarray(resultString);我有JSONException07-17 19:48:53.650:W/System.err(15185):org.json.JSONException:Value“xxxxxx”07-17 19:48:53.660:W/System.err(15185):at org.json.json.typeMismatch(json.java:100)共享Stacktrace。这可能会给我们提供更多细节。07-17 19:48:53.650:W/System.err(15185):org.json.JSONException:Value“xxxxxx”07-17 19:48:53.660:W/System.err(15185):at org.json.json.typemissmatch(json.java:100)共享堆栈跟踪。这可能会给我们更多的细节。
JSONArray values = new JSONArray(resultString);
for(int i = 0 ; i < values.length(); i++){
    JSONObject object = (JSONObject) values.get(i); 
    String id = object.getString("id");
    //the same for the rest
}
JsonElement jelement = new JsonParser().parse("json text");