android - Jackson annotations, REST and json array parsing -


i have finish project of programmer, started jackson annotations , rest apis. have no experience it, , struggling hours now. need parse json array this:

{ ... "id_s": "3011", "no_s": "suteki", "fl": [          {              "v": "1",              "m": "0",          "id_fs": "243",            "f_c": "2013-08-09 14:43:54",           id_tf": "3",            "u_c": "aaa",            _u_c": "1347678779",              "c": "carlos rojas",            "c_c": "1"            }       ] }   

existing class like:

@ebean @jsonignoreproperties(ignoreunknown = true) public class item implements serializable, mapmarker { private static final long serialversionuid = 1l;  @jsonproperty("id_s") protected int id;  @jsonproperty("id_sucursal") public void setid_sucursal(int id_sucursal) {     this.id = id_sucursal; }  @jsonproperty("id_fb") protected string idfacebook;  @jsonproperty("no_s") private string name;  ... } 

i've read here how parse array, how jsonresponsestring using jackson annotations? miss?

thanks!

aside missing lots of things answer question, guessing not sure how json arrays map java objects. if so, should straight-forward: map json arrays either java arrays, or collections (like lists):

public class item { // i'll skip getters/setters; can add if them   public string id_s;   public string no_s;    public list<entry> fl; }  public class entry {   public string v; // or maybe it's supposed 'int'? can use   public string m;   public int id_fs; // odd it's string in json; can convert   public string f_c; // java.util.date, format non-standard (fixable)   // , on. } 

and either read json objects:

objectmapper mapper = new objectmapper(); item requesteditem = mapper.readvalue(inputstream, item.class); // or string, url etc // or, write stream outputstream out = ...; item result = ...; mapper.writevalue(out, result); // or convert string string jsonasstring = mapper.writevalueasstring(result); // note, however, converting string, outputting less efficient 

i hope helps.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -