Skip to main content
added 6 characters in body
Source Link
Pratik Butani
  • 62.6k
  • 63
  • 289
  • 454
JsonParser parser =  new JsonParser(); 

JsonElement jsonElement = parser.parse(json);
JsonObject jsonObj = jsonElement.getAsJsonObject(); 

JsonArray feed = new JsonArray();
feed = jsonObj.getAsJsonArray("feed"); 

JsonObject jsonOb = feed.get(0).getAsJsonObject();
String value = jsonOb.get("cat2").getAsString();

This is how you can get value of cat2. You will need to add com.google.gson library to compile this code.

JsonParser parser =  new JsonParser();
JsonElement jsonElement = parser.parse(json);
JsonObject jsonObj = jsonElement.getAsJsonObject();
JsonArray feed = new JsonArray();
feed = jsonObj.getAsJsonArray("feed");
JsonObject jsonOb = feed.get(0).getAsJsonObject();
String value = jsonOb.get("cat2").getAsString();

This is how you can get value of cat2. You will need to add com.google.gson library to compile this code.

JsonParser parser =  new JsonParser(); 

JsonElement jsonElement = parser.parse(json);
JsonObject jsonObj = jsonElement.getAsJsonObject(); 

JsonArray feed = new JsonArray();
feed = jsonObj.getAsJsonArray("feed"); 

JsonObject jsonOb = feed.get(0).getAsJsonObject();
String value = jsonOb.get("cat2").getAsString();

This is how you can get value of cat2. You will need to add com.google.gson library to compile this code.

deleted 2 characters in body
Source Link
Kruti Patel
  • 1.5k
  • 2
  • 24
  • 37
JsonParser parser =  new JsonParser();
JsonElement jsonElement = parser.parse(json);
JsonObject jsonObj = jsonElement.getAsJsonObject();
JsonArray feed = new JsonArray();
feed = jsonObj.getAsJsonArray("feed");
JsonObject jsonObjectjsonOb = feed.getAsJsonObjectget(0).getAsJsonObject();
String value = jsonObjectjsonOb.get("cat2").getAsString();

This is how you can get value of cat2. You will need to add com.google.gson library to compile this code.

JsonParser parser =  new JsonParser();
JsonElement jsonElement = parser.parse(json);
JsonObject jsonObj = jsonElement.getAsJsonObject();
JsonArray feed = new JsonArray();
feed = jsonObj.getAsJsonArray("feed");
JsonObject jsonObject = feed.getAsJsonObject(0);
String value = jsonObject.get("cat2");

This is how you can get value of cat2. You will need to add com.google.gson library to compile this code.

JsonParser parser =  new JsonParser();
JsonElement jsonElement = parser.parse(json);
JsonObject jsonObj = jsonElement.getAsJsonObject();
JsonArray feed = new JsonArray();
feed = jsonObj.getAsJsonArray("feed");
JsonObject jsonOb = feed.get(0).getAsJsonObject();
String value = jsonOb.get("cat2").getAsString();

This is how you can get value of cat2. You will need to add com.google.gson library to compile this code.

Source Link
Kruti Patel
  • 1.5k
  • 2
  • 24
  • 37

JsonParser parser =  new JsonParser();
JsonElement jsonElement = parser.parse(json);
JsonObject jsonObj = jsonElement.getAsJsonObject();
JsonArray feed = new JsonArray();
feed = jsonObj.getAsJsonArray("feed");
JsonObject jsonObject = feed.getAsJsonObject(0);
String value = jsonObject.get("cat2");

This is how you can get value of cat2. You will need to add com.google.gson library to compile this code.