java - How to deserialize an PHP array with GSON -


in php serialize array json_encode try read on android device gson. android crashes fatal exception. can't work of examples i've seen. think caused json string. starts index of array (19 , 17 in example below), , haven't seen examples of type of json string. examples have seen start property names , not index / cpunter.

here's json example:

{"19":{"id":"1262","username":"abc","telnr":"0123456789","created":"sun, 08 aug 2010 10:29:06 +0200","email":"e@mail.com","code":null},"17":{"id":"1259","username":"cdef","telnr":"9876543210","created":"sun, 08 aug 2010 10:29:06 +0200","email":"mail@domain.com","code":null},

among many other combinations tried following 2 examples:

type listtype = new typetoken<list<string>>(){}.gettype();  list<string> personlist = new gson().fromjson(json, listtype); 

and

type playertype = new typetoken<list<player>>(){}.gettype();  list<player> players = new gson().fromjson(json.tostring(), playertype); 

i follow error:

threadid=1: thread exiting uncaught exception fatal exception: main java.lang.runtimeexception: unable start activity componentinfo{...}:java.lang.nullpointerexception 

i have player class / bean can hold id, username, telnr, created, email , code properties. hope can provide me example of gson code work on json string. thanks.

the names of properties in json object (the "19" , "17" above) must valid javascript identifiers. can contain letters, digits, underscores, , dollar signs, but may not start digit. must assign different keys or remove keys altogether form javascript array.

$values = array_values($arraywithkeys); 

Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -