最近在学习Gson框架的使用,双层实体类嵌套可以解析出来,但是再多就出错。如下面这段json字符串
{"state":"1","country":[{"province":"山东省","state":"2",{"city":"临沂市","state":"3"}},{"province":"北京市","state":"2",{"city":"临沂市","state":"3"}}]}
下面是我将json转成字符串
String json = "{\"state\":\"1\",\"country\":[{\"province\":\"山东省\",\"state\":\"2\",{\"city\":\"临沂市\",\"state\":\"3\"}},{\"province\":\"北京市\",\"state\":\"2\",{\"city\":\"临沂市\",\"state\":\"3\"}}]}";
这是我用到的三个实体类
这是解析方法
最后是报的错
------解决思路----------------------
json数据有问题
{"province":"山东省","state":"2",{"city":"临沂市","state":"3"}
例如这一段,改成
{"province":"山东省","state":"2","City":{"city":"临沂市","state":"3"}
这样才正确