Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.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 Gson无法分析嵌套的字符串对象_Java_Android_Arrays_Json_Gson - Fatal编程技术网

Java Gson无法分析嵌套的字符串对象

Java Gson无法分析嵌套的字符串对象,java,android,arrays,json,gson,Java,Android,Arrays,Json,Gson,如何解析嵌套对象 [{ "id": 100500, "products": "[{\"id\":45,\"title\":\"All Product\"]" }] 模范班 public class Store { public long id; public List<Product> products; } 公共类存储{ 公共长id; 公开上市产品; } 不,它将解析 public class Store {

如何解析嵌套对象

 [{
       "id": 100500,
       "products": "[{\"id\":45,\"title\":\"All Product\"]"
    }]
模范班

public class Store {
      public  long id;
      public  List<Product> products;

}
公共类存储{
公共长id;
公开上市产品;
}
不,它将解析

public class Store {
      public  long id;
      public  List<Product> products;

}

Gson mGson= new Gson();
storeList=mGson.fromJson(json, Store.class);
storeList.getStores().get(0).getProducts().get(1);
公共类存储{
公共长id;
公开上市产品;
}
Gson mGson=新的Gson();
storeList=mGson.fromJson(json,Store.class);
storeList.getStores().get(0.getProducts().get(1);
不,它将解析

public class Store {
      public  long id;
      public  List<Product> products;

}

Gson mGson= new Gson();
storeList=mGson.fromJson(json, Store.class);
storeList.getStores().get(0).getProducts().get(1);
公共类存储{
公共长id;
公开上市产品;
}
Gson mGson=新的Gson();
storeList=mGson.fromJson(json,Store.class);
storeList.getStores().get(0.getProducts().get(1);
Hi将您的Gson更改为

{
  "Id": "100500",
  "products": [

      {
        "id": 1,
        "title": "title 1"
      },
      {
         "id": 2,
         "title": "title 2"
      },
      {
        "id": 3,
          "title": "title 3"
      } 

  ]
}
嗨,把你的Gson换成

{
  "Id": "100500",
  "products": [

      {
        "id": 1,
        "title": "title 1"
      },
      {
         "id": 2,
         "title": "title 2"
      },
      {
        "id": 3,
          "title": "title 3"
      } 

  ]
}

我用替换字符串解算我用替换字符串解算