-7

have can I convert this complex json to java class? I am using GSON for parse JSON data.

http://api.feedzilla.com/v1/categories/26/articles.json

Something like this:

Parsing a complex Json Object using GSON in Java

EDIT: I followed this exemple Complex JSON OBJECT USING GSON IN JAVA

This is my class Article:

public class Article {
public String publish_date;
public String source;
public String source_url;
public String summary;
public String title;
public String url;

}

DataStorage class:

public class DataStorage {
public static List<Article> article;

}

MyActivity class:

public class MyActivity extends Activity {
/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    AsyncHttpClient httpClient = new AsyncHttpClient();

    httpClient.get("http://api.feedzilla.com/v1/categories/26/articles.json", null,
            new JsonHttpResponseHandler()
            {
                @Override
                public void onSuccess(int statusCode, Header[] headers, JSONArray response)
                {
                    Log.d("HTTP_RESPONSE", response.toString());

                    Gson myGson = new Gson();
                    DataStorage ac = myGson.fromJson(response.toString(), DataStorage.class);

                    Log.d("HTTP_RESPONSE", response.toString());

                    //listView.setAdapter(new Adapter(getApplicationContext()));

                }
            }
    );
}

}

After i compile it shows in logcat, why?

12-30 16:22:20.044    1156-1156/com.example.Articles W/JsonHttpResponseHandler﹕ onSuccess(int, Header[], JSONObject) was not overriden, but callback was received
Community
  • 1
  • 1
  • You seem to have linked to a question that tells you how to marshall a nested JSON file to an object in Java. You should try to follow this example, and edit your question if you are stuck, showing your progress and which part you're stuck on. To begin with, try converting a small JSON object. – ataulm Dec 29 '14 at 19:41
  • possible duplicate of [Parsing a complex Json Object using GSON in Java](http://stackoverflow.com/questions/19551242/parsing-a-complex-json-object-using-gson-in-java) – Lorenz Meyer Dec 29 '14 at 20:00

1 Answers1

1

Use a JSON beautifier (like http://jsonformatter.curiousconcept.com/) so you can see better what's in there. Then, create classes, like this:

class article {
    String publish_date;
    String title;
    ...