Archives: JSON

Android Realm – Insert JSON Object

Realm Insert JSON Object Example in Android and Java – Realm Database

— You can add a JSON object that maps to a RealmObject to Realm.
— The JSON object can be a String, a JSONObject or an InputStream.
— Realm will ignore any properties in the JSON not defined by the RealmObject.



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