如何在Android中使用带有复杂JSON的GSON的TypeAdapter

时间:2017-05-24 14:56:07

标签: android json adapter gson

我有一个复杂的JSON,如下所示。

{
 "nodes": [
   {
  "name": "some name",
  "links": {
    "link_name_1": [
      "name 1",
      "name 2"
    ],
    "link_name_2": [
      "name 1",
      "name 2"
    ]
  },
  "properties": {
    "property_name_xyz": {
      "property_name_xyz_1": "some value",
      "property_name_xyz_2": "some value"
    },
    "property_name_abc": {
      "property_name_abc_1": "some value",
      "property_name_abc_2": "some value",
      "property_name_abc_3": "some value"
    },
    "property_name_pqr": {
      "property_name_pqr_1": "some value",
      "property_name_pqr_2": "some value",
      "property_name_pqr_3": "some value",
      "property_name_pqr_4": "some value"
    }
   }
  },
  { 
   another similar object with different property names inside properties
  } 

 ]
}

我已经使用http://www.jsonschema2pojo.org/

为上述所有内容创建了一个PoJos

我想知道如何使用TypeAdapter来区分不同的对象。可以根据每个Node对象的属性进行区分

 nodes

0 个答案:

没有答案