| Interface | Description |
|---|---|
| Json |
Facade for JSON parser and serializer.
|
| Exception | Description |
|---|---|
| JsonException |
Not checked exception thrown when JSON parsing or serialization fails for some reasons.
|
Json facade to supplies (de)serialization services.
As a consequence using JSON package is straightforward: invoke facade supplied methods, see samples.
Json json = ServiceLoader.load(Json.class).iterator().next();
...
// parse Page instance from JSON object stream
Page page = json.parse(reader, Page.class);
// parse not homogeneous array from JSON array stream
Object[] parameters = json.parse(reader, new Type[] { double.class, Page.class, String.class, boolean.class });
// parse list of objects from JSON formatted string
List<Page> pages = json.parse(jsonList, new GType(List.class, Page.class));
// serialize Page instance on JSON stream
json.stringify(writer, page);
// serialize Page instance to JSON formatted string
String jsonObject = json.stringify(page);
Method names used on JSON facade should be familiar to ECMA Script programmers.
Anyway, do not confuse with type variables, a.k.a. type parameters. Those are not present into bytecode and are not considered by JSON package logic.
class property from JSON start.
{"class":"js.net.Event","id":1234 ... }
Copyright © 2020. All rights reserved.