java - How do I deserialize this JSON type -


i have json looks this:

{     "results": {         "exchange": [             "site.com",             {                 "currency": "usd",                 "last_traded": "2015.24"             }         ]     } } 

how last_traded value?

i wrote pojo this, can't seem find way key-value inside exchange array.

public class exchangecontainer {      @expose     private results results;      public results getresults() {         return results;     }      public void setresults(results results) {         this.results = results;     }      @override     public string tostring() {         return tostringbuilder.reflectiontostring(this);     }  }  public class results {      @expose     private list<string> exchange = new arraylist<string>();      public list<string> getexchange() {         return exchange;     }      public void setexchange(list<string> exchange) {         this.exchange = exchange;     }      @override     public string tostring() {         return tostringbuilder.reflectiontostring(this);     } } 

i'm using gson deserialize json.

so in order me traverse through model is:

exchangecontainer response;  string rate = response.getresults().getexchange().get(1); // how continue? 

and i'm stuck.

implement interface using implements jsondeserializer in class

and override deserialize method.

example link - http://www.javacreed.com/gson-deserialiser-example/


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -