public class JsonUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ACCEPT_HEADER
An HTTP Accept header that prefers JSONLD.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Object |
fromInputStream(java.io.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 java.lang.Object |
fromReader(java.io.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 java.lang.Object |
fromString(java.lang.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 java.lang.Object |
fromURL(java.net.URL url,
org.apache.http.impl.client.CloseableHttpClient httpClient)
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 java.lang.Object |
fromURLJavaNet(java.net.URL url)
Fallback method directly using the
HttpURLConnection
class for cases where servers do not interoperate correctly with Apache
HTTPClient. |
static org.apache.http.impl.client.CloseableHttpClient |
getDefaultHttpClient() |
static java.lang.String |
toPrettyString(java.lang.Object jsonObject)
Writes the given JSON-LD Object out to a String, using indentation and
new lines to improve readability.
|
static java.lang.String |
toString(java.lang.Object jsonObject)
Writes the given JSON-LD Object out to a String.
|
static void |
writePrettyPrint(java.io.Writer writer,
java.lang.Object jsonObject)
Writes the given JSON-LD Object out to the given Writer, using
indentation and new lines to improve readability.
|
public static final java.lang.String ACCEPT_HEADER
public static java.lang.Object fromInputStream(java.io.InputStream input)
throws java.io.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.java.io.IOException - If there was an IO error during parsing.public static java.lang.Object fromReader(java.io.Reader reader)
throws java.io.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.java.io.IOException - If there was an IO error during parsing.public static java.lang.Object fromString(java.lang.String jsonString)
throws java.io.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.java.io.IOException - If there was an IO error during parsing.public static java.lang.String toPrettyString(java.lang.Object jsonObject)
throws com.fasterxml.jackson.core.JsonGenerationException,
java.io.IOException
jsonObject - The JSON-LD Object to serialize.com.fasterxml.jackson.core.JsonGenerationException - If there is a JSON error during serialization.java.io.IOException - If there is an IO error during serialization.public static java.lang.String toString(java.lang.Object jsonObject)
throws com.fasterxml.jackson.core.JsonGenerationException,
java.io.IOException
jsonObject - The JSON-LD Object to serialize.com.fasterxml.jackson.core.JsonGenerationException - If there is a JSON error during serialization.java.io.IOException - If there is an IO error during serialization.public static void writePrettyPrint(java.io.Writer writer,
java.lang.Object jsonObject)
throws com.fasterxml.jackson.core.JsonGenerationException,
java.io.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.java.io.IOException - If there is an IO error during serialization.public static java.lang.Object fromURL(java.net.URL url,
org.apache.http.impl.client.CloseableHttpClient httpClient)
throws java.io.IOException
JsonLdApi and JsonLdProcessor methods.url - The JsonLdUrl to resolvehttpClient - The CloseableHttpClient to use to resolve the URL.com.fasterxml.jackson.core.JsonParseException - If there was a JSON related error during parsing.java.io.IOException - If there was an IO error during parsing.public static java.lang.Object fromURLJavaNet(java.net.URL url)
throws java.io.IOException
HttpURLConnection
class for cases where servers do not interoperate correctly with Apache
HTTPClient.url - The URL to access.com.fasterxml.jackson.core.JsonParseException - If there was a JSON related error during parsing.java.io.IOException - If there was an IO error during parsing.public static org.apache.http.impl.client.CloseableHttpClient getDefaultHttpClient()