Golo includes the JSON Simple library to provide JSON support.
While json-simple
only supports encoding from lists and maps, this API brings support for sets,
arrays, Golo tuples, dynamic objects and structs.
Given a simple data structure, we can obtain a JSON representation:
let data = map[ ["name", "Somebody"], ["age", 69], ["friends", list[ "Mr Bean", "John B", "Larry" ]] ] let asText = JSON.stringify(data)
Given some JSON as text, we can get back a data structure:
let data = JSON.parse(text) println(data: get("name"))
The gololang.JSON
module also provides helpers for JSON serialization and deserialization
with both dynamic objects and structs.