java - Re-using top level models with gson -


i using gson parse json response.

if have json structure looks this:

"x" : {      "y" : [          {              "a" : "x",              "b" : "y"            },        ....      ] }, "a" : {      "y" : [          {              "c" : "1",              "d" : "2"          },         ....      ]   } 

i want able re-use "y" , have contents of y parsed different models @ runtime.

if define top level model topjson.java , define fields as

private modelx x; private modela a; 

and define modelx.java as:

private modely y; 

and modela.java :

private modely y; 

and modely.java :

private list<something> results; 

how can use generics ensure modely can contain different types of models? how can handle case when don't know structure of json looks like?


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -