How to parse a complex JSON String got from a webservice response with GSON in Java?

It's layers of an onion. Peel them one at a time. You can use the instanceof operator and/or getClass().getName() method calls to figure out what you have at each step and double-check it's as expected.

Up vote 0 down vote favorite share g+ share fb share tw.

I am new to Json/Gson. I have already looked all around the internet for help, but I have seen nothing so similar to what I need to parse. So I am posting here, any help will be appreciated.

I am receiving as a response from the webservice I am calling this Json String: Json String = {"courses":{"links": {"href":"xp.student.com/courses/6364145","rel":"s..., {"links": {"href":"xp.student.com/courses/6364143","rel":"s..., {"links": {"href":"xp.student.com/courses/6364144","rel":"s... I have already done code up to the point where I get the "Json String": InputStreamReader reader = new InputStreamReader(httpConn.getInputStream()); in = new BufferedReader(reader); Gson gson = new Gson(); Course courses = new Gson(). FromJson(in,Course. Class); I have also created the following classes: import ccSample.Type.Course.

Link; public class Course { public Link links; } public class Link{ public String href; public String rel; public String title; public String getHref() { return href; } public void setHref(String href) { this. Href = href; } public String getRel() { return rel; } public void setRel(String rel) { this. Rel = rel; } public String getTitle() { return title; } public void setTitle(String title) { this.

Title = title; } } but I am just getting a null courses object and do not know what I am missing, any suggestions corrections are welcome! Thank you very much :) json gson link|improve this question asked Jan 17 at 0:35user11528981.

Ahh, gotcha.. You need another wrapper for the courses since in the reply its contained in another json object public class Reply { private Course courses; public void setCourses(Course courses) { this. Courses = courses; } public Course getCourses() { return courses; } } And then Reply reply = new Gson(). FromJson(in,Reply.

Class); Should do it :).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions