Archives:

Java – Read JSON Data Simple Example

In below example, it uses JSONParser to read and display JSON data from a file named “test.json“ using JSON.simple, a simple Java library for JSON processing.

Output:

prasanna
25
msg 1
msg 2
msg 3

Java – Write JSON Data Simple Example

In below example, it writes JSON data via JSONObject and JSONArray, and save it into a file named “test.json“ using JSON.simple, a simple Java library for JSON processing.

Output: (see content of file “test.json”)

{
“age”:25,
“name”:”prasanna”,
“messages”:[“msg 1″,”msg 2″,”msg 3”]
}

Java – Read XML File – SAX Parser

SAX Parser is faster and uses less memory than DOM parser.
file.xml

ReadXMLFile.java