Skip to content

iahmadgad/java-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java JSON package

Install:

  • Download the latest release.
  • Add package to your build using command-line, or your IDE like Eclipse or Netbeans.

How to use:

Here is an example on how to make a new JSON object:

JSONObject obj = new JSONObject();
obj.put("$id", "User-info");
obj.put("name", "Gelobt");
obj.put("age", 16);
obj.put("isAlive", true);

& here is an example on how to make a new JSON array:

JSONArray arr = new JSONArray();
arr.add("Java");
arr.add("C++");
arr.add("Cats");

then you can put this array in the JSON object you`ve just created:

obj.put("THINGS I LOVE", arr);

last but not least, write this JSON object in a JSON file:

obj.write(new File("User-info.json"));

& here is your JSON file:

{
     "isAlive":true
     ,"name":"Gelobt"
     ,"THINGS I LOVE":     [
          "Java"
          ,"C++"
          ,"Cats"
     ]

     ,"age":16
     ,"$id":"User-info"
}

Repo Index:

License:

About

Java implementation of JSON ☕

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages