Skip to content

AnwarShahriar/JsonPie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

###Sample Json

{
  "name": {
    "firstName": "Shahriar",
    "lastName": "Anwar"
  },
  "contacts":[
    "1234",
    "5678",
    "9876"
  ],
  "doc":[
    {
      "title": "one",
      "text": "this is doc one"
    },
    {
      "title": "two",
      "text": "this is doc two"
    },
    {
      "title": "three",
      "text": "this is doc three"
    }
  ]
}

You can just parse everything like that:

  JSONPie pie = new JSONPie(jsonString);
  String fullName = pie.getString("name->firstName") + " " + pie.getString("name->lastName");
  System.out.println(fullName);

  for (int i = 0; i < pie.getJSONArray("contacts").length(); i++) {
    String contact = pie.getString("contacts[" + i + "]");
    System.out.println(contact);
  }

  for (int i = 0; i < pie.getJSONArray("doc").length(); i++) {
    String title = pie.getString("doc[" + i + "] -> title");
    String text = pie.getString("doc[" + i + "] -> text");
    System.out.println(title + "\n" + text);
  }

About

A simple interface for parsing JSON based on org.json which provides a simple query feature to extract data from json.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages