This library offers a more object oriented way to parse json data.
- Declaritive design
- Everything is immutable
- Everything uses interfaces
- Easy expandable
- No unnecessary exception throwing
- No object mapping
- Supports conversion from and to a json file or anything else
- Own json sources or targets can be defined
- Uses mutation testing
A json object can be created like this:
val json = JsonObject(
"firstKey" to JsonString("firstValue"),
"secondKey" to JsonInt(323),
"thirdKey" to JsonObject(
"fourthKey" to JsonArray(
"a" to JsonBoolean("true"),
"b" to JsonInt("342")
)
)
)
To export this data:
json.exportTo(
FileTarget("path")
)
Result:
{
"firstKey": "firstValue",
"secondKey": 323,
"thirdKey": {
"fourthKey": [
1, 2, 3, 4, 5
]
}
}
To import json data, one has to specify the source of it:
JsonObject(
FileSource("path")
)
Other sources are also possible. The JsonObject can be constructed by using a string, a file or other json objects. It just needs a class that implements the Source interface.