【发布时间】:2015-02-13 19:48:05
【问题描述】:
String jsonStr = HelperInputStream.convertInputStreamToString(inputStream);
if (jsonStr == null) {
return;
}
String code,message = "";
try {
JSONObject object = new JSONObject(jsonStr);
Log.e("code:" , object.getString("subject"));
jsonStr 结果是:
[{"code":"1","subject":"you have new message"}]
不幸的是我得到这个错误是catch:
org.json.JSONException: Value [{"subject":"you have new message","code":"1"}] of type org.json.JSONArray cannot be converted to JSONObject
什么是我的代码问题。在服务器中我只有这个代码:
<?php
echo json_encode(array(
array(
'code'=>'1',
'subject'=>"you have new message",
)
));
?>
【问题讨论】:
标签: android json android-json