Package blue.endless.jankson
Class Jankson
java.lang.Object
blue.endless.jankson.Jankson
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Jankson.Builderbuilder()<T> TfromJson(JsonObject obj, Class<T> clazz) <T> T<T> TfromJsonCarefully(JsonObject obj, Class<T> clazz) Converts a JsonObject into an object of the specified class, in fail-fast mode, throwing an exception proactively if problems arise<T> TfromJsonCarefully(String json, Class<T> clazz) Converts a String of json into an object of the specified class in fail-fast mode, throwing an exception proactively if problems arise.load(InputStream in) loadElement(File f) Experimental: Parses the supplied File as a JsonElement, which may or may not be an object at the root levelExperimental: Parses the supplied InputStream as a JsonElement, which may or may not be an object at the root levelExperimental: Parses the supplied String as a JsonElement, which may or may not be an object at the root level<T> voidpush(ParserContext<T> t, Consumer<T> consumer) Pushes a context onto the stack.voidthrowDelayed(SyntaxError syntaxError) <T> JsonElementtoJson(T t) <T> JsonElementtoJson(T t, Marshaller alternateMarshaller)
-
Method Details
-
load
- Throws:
SyntaxError
-
load
- Throws:
IOExceptionSyntaxError
-
load
- Throws:
IOExceptionSyntaxError
-
loadElement
Experimental: Parses the supplied String as a JsonElement, which may or may not be an object at the root level- Throws:
SyntaxError
-
loadElement
Experimental: Parses the supplied File as a JsonElement, which may or may not be an object at the root level- Throws:
IOExceptionSyntaxError
-
loadElement
Experimental: Parses the supplied InputStream as a JsonElement, which may or may not be an object at the root level- Throws:
IOExceptionSyntaxError
-
fromJson
-
fromJson
- Throws:
SyntaxError
-
fromJsonCarefully
public <T> T fromJsonCarefully(String json, Class<T> clazz) throws SyntaxError, DeserializationException Converts a String of json into an object of the specified class in fail-fast mode, throwing an exception proactively if problems arise.- Parameters:
json- A string containing json data to be unpackedclazz- The class to convert the data into- Returns:
- An object representing the data in json
- Throws:
SyntaxError- If the json cannot be parsedDeserializationException- If the conversion into an instance of the specified type fails
-
fromJsonCarefully
Converts a JsonObject into an object of the specified class, in fail-fast mode, throwing an exception proactively if problems arise- Parameters:
obj- A JsonObject holding the data to be unpackedclazz- The class to convert the data into- Returns:
- An object of the specified class, holding the data from json
- Throws:
DeserializationException- If the conversion into an instance of the specified type fails
-
toJson
-
toJson
-
push
Pushes a context onto the stack. MAY ONLY BE CALLED BY THE ACTIVE CONTEXT -
getMarshaller
-
builder
-
throwDelayed
-