1

I have the sample json data below. How can I parse it?

"posts": [12]
0:  {
"id": 6429
"type": "post"
"slug": "pyo-puth-remix-lyrics-dj-frenzy"
"url": "http://song.com/2016/06/remix-lyrics.html"
"status": "publish"
"title": " Remix Lyrics – DJ Frenzy"
"title_plain": " Remix Lyrics "
"content": "<p><strong>Remix lyrics</strong> is latest  single track produced by <strong><a >"
cf-
  • 8,598
  • 9
  • 36
  • 58
Deep
  • 89
  • 1
  • 7

1 Answers1

4

Do not listen this guys in comments. You do not have to reinvent the wheel and implement your own Json parser. You can use any library for example Moshi:

Create Json representation:

public class Dummy {
    int value1;
    List<InnerDummy> valueList;
}

public class InnerDummy {
    int value1;
    boolean value2;
}

Use them to parse your Json:

String json = "...";
Moshi moshi = new Moshi.Builder().build();
JsonAdapter<Dummy> jsonAdapter = moshi.adapter(Dummy.class);
Dummy dummy = jsonAdapter.fromJson(json);
Artur Szymański
  • 1,639
  • 1
  • 19
  • 22