Android 我的JSON响应正确吗?为什么我在尝试检索时会看到这个异常?
我的问题是我有一个asp。web服务。。当我调用它时,它会给出以下结果:Android 我的JSON响应正确吗?为什么我在尝试检索时会看到这个异常?,android,json,web-services,Android,Json,Web Services,我的问题是我有一个asp。web服务。。当我调用它时,它会给出以下结果: [ { "_OrderDetails": [ { "ProductName": "FUCHS SUPER GT SAE 10W30 6X5 / FP10100010102", "TotalAfterDiscount_Lc": "7500", "MeasureUnitName": "كرتونة", "TotalPrice_Lc": "7
[
{
"_OrderDetails": [
{
"ProductName": "FUCHS SUPER GT SAE 10W30 6X5 / FP10100010102",
"TotalAfterDiscount_Lc": "7500",
"MeasureUnitName": "كرتونة",
"TotalPrice_Lc": "7500",
"PricePerUnit_Lc": "75",
"Quantity": "100"
}
],
"Id": "274",
"OrderDate": "4/10/2014 12:00:00 AM",
"Number": "16",
"CustomerName": "الأسد",
"Note": ""
}
]
在主要活动中,我做了以下几点:
Gson gson = new Gson();
Log.e("Response", responseJSON);
if (responseJSON != null) {
try {
JSONObject jsonObj = new JSONObject(responseJSON);
//JSONArray jsonarr =new JSONArray();
// details=jsonObj.getJSONObject(0);
// Getting JSON Array node
details = jsonObj.getJSONArray(TAG_CONTACTS);
// looping through All Contacts
for (int i = 0; i < details.length(); i++) {
JSONObject c = details.getJSONObject(i);
String product = c.getString(TAG_PRODUCT);
Log.e("prodeuct",product+"");
}
Gson-Gson=new-Gson();
Log.e(“响应”,responseJSON);
if(responseJSON!=null){
试一试{
JSONObject jsonObj=新的JSONObject(responseJSON);
//JSONArray jsonarr=新的JSONArray();
//details=jsonObj.getJSONObject(0);
//获取JSON数组节点
details=jsonObj.getJSONArray(TAG_联系人);
//通过所有触点循环
对于(int i=0;i
我在logcat中正确地看到了响应,但当我尝试从数组中获取任何对象时,我看到一个JSON异常,它说:
JSON数组无法转换为JSON对象
有人能帮我吗?换成JSONArray
if (responseJSON != null) {
try {
JSONArray array = new JSONArray(responseJSON)
}
张东荣
if (responseJSON != null) {
try {
JSONArray array = new JSONArray(responseJSON)
}
张东荣
if (responseJSON != null) {
try {
JSONArray array = new JSONArray(responseJSON)
}
张东荣
if (responseJSON != null) {
try {
JSONArray array = new JSONArray(responseJSON)
}
因为您的json返回jsonarray,并且您正在尝试访问jsonobject 更改您的代码:
if (responseJSON != null) {
try {
JSONArray jsonObj = new JSONArray(responseJSON);
// looping through All Contacts
for (int i = 0; i < jsonObj.length(); i++) {
// your code
}
if(responseJSON!=null){
试一试{
JSONArray jsonObj=新JSONArray(responseJSON);
//通过所有触点循环
for(int i=0;i
因为您的json返回jsonarray,并且您正在尝试访问jsonobject
更改您的代码:
if (responseJSON != null) {
try {
JSONArray jsonObj = new JSONArray(responseJSON);
// looping through All Contacts
for (int i = 0; i < jsonObj.length(); i++) {
// your code
}
if(responseJSON!=null){
试一试{
JSONArray jsonObj=新JSONArray(responseJSON);
//通过所有触点循环
for(int i=0;i
因为您的json返回jsonarray,并且您正在尝试访问jsonobject
更改您的代码:
if (responseJSON != null) {
try {
JSONArray jsonObj = new JSONArray(responseJSON);
// looping through All Contacts
for (int i = 0; i < jsonObj.length(); i++) {
// your code
}
if(responseJSON!=null){
试一试{
JSONArray jsonObj=新JSONArray(responseJSON);
//通过所有触点循环
for(int i=0;i
因为您的json返回jsonarray,并且您正在尝试访问jsonobject
更改您的代码:
if (responseJSON != null) {
try {
JSONArray jsonObj = new JSONArray(responseJSON);
// looping through All Contacts
for (int i = 0; i < jsonObj.length(); i++) {
// your code
}
if(responseJSON!=null){
试一试{
JSONArray jsonObj=新JSONArray(responseJSON);
//通过所有触点循环
for(int i=0;i
使用它查看json并相应地解析它。您正在使用json数组作为json对象
使用这些:
JSONObject jsonObj = new JSONObject(responseJSON);
到
使用它查看json并相应地解析它。您正在使用json数组作为json对象
使用这些:
JSONObject jsonObj = new JSONObject(responseJSON);
到
使用它查看json并相应地解析它。您正在使用json数组作为json对象
使用这些:
JSONObject jsonObj = new JSONObject(responseJSON);
到
使用它查看json并相应地解析它。您正在使用json数组作为json对象
使用这些:
JSONObject jsonObj = new JSONObject(responseJSON);
到
也许是因为这个非英语字符的缘故,这个
JSONObject jsonObj=new JSONObject(responseJSON);
toJSONArray jr=new JSONArray(responseJSON);
@user3534834您的解析不正确。请阅读一些关于解析JSON的教程,可能是因为这个JSONObject JSONObject(responseJSON);
toJSONArray jr=new JSONObject JSONArray(responseJSON)
toJSONArray jr=new JSONArray(responseJSON)
这一行给了我一个错误:details=jr.getJSONArray(TAG_CONTACTS);@user3534834您的解析不正确。去读一些关于解析json的教程也许是因为这个原因toJSONArray jr=new-JSONArray(responseJSON);
这一行给了我一个错误:details=jr.getJSONArray(TAG\u联系人)@user3534834您的解析不正确。请阅读一些关于解析JSON的教程,可能是因为这个JSONObject JSONObject(responseJSON);
toJSONArray jr=new JSONObject JSONArray(responseJSON)
toJSONArray jr=new JSONArray(responseJSON)
这一行给了我一个错误:details=jr.getJSONArray(TAG_CONTACTS);@user3534834您的解析不正确。请阅读一些关于解析json的教程