public class JsonUtils extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
ACCEPT_HEADER
An HTTP Accept header that prefers JSONLD.
|
Constructor and Description |
---|
JsonUtils() |
Modifier and Type | Method and Description |
---|---|
static Object |
fromInputStream(InputStream input)
Parses a JSON-LD document from the given
InputStream to an object
that can be used as input for the JsonLdApi and
JsonLdProcessor methods.Uses UTF-8 as the character encoding when decoding the InputStream. |
static Object |
fromInputStream(InputStream input,
String enc)
Parses a JSON-LD document from the given
InputStream to an object
that can be used as input for the JsonLdApi and
JsonLdProcessor methods. |
static Object |
fromReader(Reader reader)
Parses a JSON-LD document from the given
Reader to an object that
can be used as input for the JsonLdApi and
JsonLdProcessor methods. |
static Object |
fromString(String jsonString)
Parses a JSON-LD document from a string to an object that can be used as
input for the
JsonLdApi and JsonLdProcessor methods. |
static Object |
fromURL(URL url)
Parses a JSON-LD document, from the contents of the JSON resource
resolved from the JsonLdUrl, to an object that can be used as input for
the
JsonLdApi and JsonLdProcessor methods. |
static String |
toPrettyString(Object jsonObject)
Writes the given JSON-LD Object out to a String, using indentation and
new lines to improve readability.
|
static String |
toString(Object jsonObject)
Writes the given JSON-LD Object out to a String.
|
static void |
write(Writer writer,
Object jsonObject)
Writes the given JSON-LD Object out to the given Writer.
|
static void |
writePrettyPrint(Writer writer,
Object jsonObject)
Writes the given JSON-LD Object out to the given Writer, using
indentation and new lines to improve readability.
|
protected static final String ACCEPT_HEADER
public static Object fromInputStream(InputStream input) throws IOException
InputStream
to an object
that can be used as input for the JsonLdApi
and
JsonLdProcessor
methods.input
- The JSON-LD document in an InputStream.com.fasterxml.jackson.core.JsonParseException
- If there was a JSON related error during parsing.IOException
- If there was an IO error during parsing.public static Object fromInputStream(InputStream input, String enc) throws IOException
InputStream
to an object
that can be used as input for the JsonLdApi
and
JsonLdProcessor
methods.input
- The JSON-LD document in an InputStream.enc
- The character encoding to use when interpreting the characters
in the InputStream.com.fasterxml.jackson.core.JsonParseException
- If there was a JSON related error during parsing.IOException
- If there was an IO error during parsing.public static Object fromReader(Reader reader) throws IOException
Reader
to an object that
can be used as input for the JsonLdApi
and
JsonLdProcessor
methods.reader
- The JSON-LD document in a Reader.com.fasterxml.jackson.core.JsonParseException
- If there was a JSON related error during parsing.IOException
- If there was an IO error during parsing.public static Object fromString(String jsonString) throws com.fasterxml.jackson.core.JsonParseException, IOException
JsonLdApi
and JsonLdProcessor
methods.jsonString
- The JSON-LD document as a string.com.fasterxml.jackson.core.JsonParseException
- If there was a JSON related error during parsing.IOException
- If there was an IO error during parsing.public static Object fromURL(URL url) throws com.fasterxml.jackson.core.JsonParseException, IOException
JsonLdApi
and JsonLdProcessor
methods.url
- The JsonLdUrl to resolvecom.fasterxml.jackson.core.JsonParseException
- If there was a JSON related error during parsing.IOException
- If there was an IO error during parsing.public static String toPrettyString(Object jsonObject) throws com.fasterxml.jackson.core.JsonGenerationException, IOException
jsonObject
- The JSON-LD Object to serialize.com.fasterxml.jackson.core.JsonGenerationException
- If there is a JSON error during serialization.IOException
- If there is an IO error during serialization.public static String toString(Object jsonObject) throws com.fasterxml.jackson.core.JsonGenerationException, IOException
jsonObject
- The JSON-LD Object to serialize.com.fasterxml.jackson.core.JsonGenerationException
- If there is a JSON error during serialization.IOException
- If there is an IO error during serialization.public static void write(Writer writer, Object jsonObject) throws com.fasterxml.jackson.core.JsonGenerationException, IOException
writer
- The writer that is to receive the serialized JSON-LD object.jsonObject
- The JSON-LD Object to serialize.com.fasterxml.jackson.core.JsonGenerationException
- If there is a JSON error during serialization.IOException
- If there is an IO error during serialization.public static void writePrettyPrint(Writer writer, Object jsonObject) throws com.fasterxml.jackson.core.JsonGenerationException, IOException
writer
- The writer that is to receive the serialized JSON-LD object.jsonObject
- The JSON-LD Object to serialize.com.fasterxml.jackson.core.JsonGenerationException
- If there is a JSON error during serialization.IOException
- If there is an IO error during serialization.Copyright © 2016. All rights reserved.