public class JsonUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ACCEPT_HEADER
An HTTP Accept header that prefers JSONLD.
|
static String |
JSONLD_JAVA_USER_AGENT
The user agent used by the default
CloseableHttpClient. |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.http.impl.client.cache.CacheConfig |
createDefaultCacheConfig() |
static org.apache.http.impl.client.CloseableHttpClient |
createDefaultHttpClient() |
static org.apache.http.impl.client.CloseableHttpClient |
createDefaultHttpClient(org.apache.http.impl.client.cache.CacheConfig cacheConfig) |
static org.apache.http.impl.client.HttpClientBuilder |
createDefaultHttpClientBuilder(org.apache.http.impl.client.cache.CacheConfig cacheConfig) |
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,
Charset 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 |
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 |
fromJsonParser(com.fasterxml.jackson.core.JsonParser jp)
Parses a JSON-LD document from the given
JsonParser 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,
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 Object |
fromURLJavaNet(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 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.
|
public static final String ACCEPT_HEADER
public static final String JSONLD_JAVA_USER_AGENT
CloseableHttpClient.
This will not be used if
DocumentLoader.setHttpClient(CloseableHttpClient) is called with
a custom client.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 fromInputStream(InputStream input, Charset 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 fromJsonParser(com.fasterxml.jackson.core.JsonParser jp) throws IOException
JsonParser to an object
that can be used as input for the JsonLdApi and
JsonLdProcessor methods.jp - The JSON-LD document in a JsonParser.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 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.public static Object fromURL(URL url, org.apache.http.impl.client.CloseableHttpClient httpClient) throws com.fasterxml.jackson.core.JsonParseException, 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.IOException - If there was an IO error during parsing.public static Object fromURLJavaNet(URL url) throws com.fasterxml.jackson.core.JsonParseException, 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.IOException - If there was an IO error during parsing.public static org.apache.http.impl.client.CloseableHttpClient getDefaultHttpClient()
public static org.apache.http.impl.client.CloseableHttpClient createDefaultHttpClient()
public static org.apache.http.impl.client.cache.CacheConfig createDefaultCacheConfig()
public static org.apache.http.impl.client.CloseableHttpClient createDefaultHttpClient(org.apache.http.impl.client.cache.CacheConfig cacheConfig)
public static org.apache.http.impl.client.HttpClientBuilder createDefaultHttpClientBuilder(org.apache.http.impl.client.cache.CacheConfig cacheConfig)
Copyright © 2018. All rights reserved.