Package playn.core
Interface Json
public interface Json
PlayN JSON parsing and serialization interface.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Represents a parsed JSON array as a simpleint->value
map.static interface
Represents a parsed JSON object as a simplestring->value
map.static interface
A JSON array that assumes all values are of a uniform JSON type.static interface
AJsonSink
that writes JSON to a string. -
Method Summary
Modifier and TypeMethodDescriptionCreates an new, emptyJson.Array
.Creates an new, emptyJson.Object
.boolean
Determines if the given object is a JSONJson.Array
.boolean
Determines if the given object is a JSONJson.Object
.Creates a newJson.Writer
, which can be used to serialize data into the JSON format.Parses the given JSON string into anJson.Object
that can be dynamically introspected.parseArray
(String json) Parses the given JSON string into anJson.Array
that can be dynamically introspected.
-
Method Details
-
createArray
Json.Array createArray()Creates an new, emptyJson.Array
. -
createObject
Json.Object createObject()Creates an new, emptyJson.Object
. -
isArray
Determines if the given object is a JSONJson.Array
. -
isObject
Determines if the given object is a JSONJson.Object
. -
newWriter
Json.Writer newWriter()Creates a newJson.Writer
, which can be used to serialize data into the JSON format.// An example of using the JSON writer interface. String jsonString = json.newWriter() .object() .value("x", 10) .value("y", 10) .object("nestedObject") .value("id", "xyz123") .end() .array("nestedArray") .value(1) .value(2) .value(3) .value(4) .value(5) .end() .end() .done(); // Produces: { 'x': 10, 'y': 10, 'nestedObject': { 'id': 'xyz123' }, 'nestedArray': [ 1, 2, 3, 4, 5 ] }
-
parse
Parses the given JSON string into anJson.Object
that can be dynamically introspected.- Throws:
playn.core.json.JsonParserException
-
parseArray
Parses the given JSON string into anJson.Array
that can be dynamically introspected.- Throws:
playn.core.json.JsonParserException
-