java - Android: Custom serialization json using gson library -


I am an early Android developer, help the server handle the serialization of Jason's response

 " "" {":" "{" Res-id ":" 11886 "," duration ":" 00:30 "}," 2 ": {" res-id ":" 13451 ", "Duration": "00:30"}, "3": {"res-id": "13452", "duration": "00:30"}, .... more items end ...} < / Code>  

(This is the real response from the server :() In the object

  ArrayList  resource;   

I ran into a problem because the object is not nested orrest Google Translation.

Create a class: < Public domain resource paused {@ Serialized name ("resource") Private map & lt; string, resource & gt; mMapResources; Public ArrayList & lt; resource & gt; getlist () {new ArrayList & lt; Resources & gt; (MMapResources.values ​​());} Public statistical class processing {@SerializedName ("res-id") private string mResId; @Serialized N Ame ("Period") Private string mDuration; }}

Then call the GSOn to:

  New GSN () fromJson ("{your_json}", resources used on class) .getList ()    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -