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”]
}