Class JsonProviders
JsonProvider
that will use the implementation of JsonProvider
found on the
classpath to create instances of JsonReader
or JsonWriter
.
If no implementation of JsonProvider
is found on the classpath a default implementation provided by this
library will be used.
At this time, additional implementations of JsonProvider
found on the classpath after the first will cause
an IllegalStateException
to be thrown. Ensure the implementation that should be used is the only one listed
in META-INF/services/com.azure.json.JsonProvider
of your JAR.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonReader
createReader
(byte[] json) Creates an instance ofJsonReader
that reads abyte[]
.static JsonReader
createReader
(byte[] json, JsonOptions options) Creates an instance ofJsonReader
that reads abyte[]
.static JsonReader
createReader
(InputStream json) Creates an instance ofJsonReader
that reads aInputStream
.static JsonReader
createReader
(InputStream json, JsonOptions options) Creates an instance ofJsonReader
that reads aInputStream
.static JsonReader
createReader
(Reader json) Creates an instance ofJsonReader
that reads aReader
.static JsonReader
createReader
(Reader json, JsonOptions options) Creates an instance ofJsonReader
that reads aReader
.static JsonReader
createReader
(String json) Creates an instance ofJsonReader
that reads aString
.static JsonReader
createReader
(String json, JsonOptions options) Creates an instance ofJsonReader
that reads aString
.static JsonWriter
createWriter
(OutputStream json) Creates an instance ofJsonWriter
that writes to anOutputStream
.static JsonWriter
createWriter
(OutputStream json, JsonOptions options) Creates an instance ofJsonWriter
that writes to anOutputStream
.static JsonWriter
createWriter
(Writer json) Creates an instance ofJsonWriter
that writes to anWriter
.static JsonWriter
createWriter
(Writer json, JsonOptions options) Creates an instance ofJsonWriter
that writes to anWriter
.
-
Method Details
-
createReader
Creates an instance ofJsonReader
that reads abyte[]
.If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to
createReader(json, new JsonOptions())
.- Parameters:
json
- The JSON represented as abyte[]
.- Returns:
- A new instance of
JsonReader
. - Throws:
NullPointerException
- Ifjson
is null.IOException
- If aJsonReader
cannot be instantiated.
-
createReader
Creates an instance ofJsonReader
that reads abyte[]
.- Parameters:
json
- The JSON represented as abyte[]
.options
-JsonOptions
to configure the creation of theJsonReader
.- Returns:
- A new instance of
JsonReader
. - Throws:
NullPointerException
- Ifjson
oroptions
is null.IOException
- If aJsonReader
cannot be instantiated.
-
createReader
Creates an instance ofJsonReader
that reads aString
.If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to
createReader(json, new JsonOptions())
.- Parameters:
json
- The JSON represented as aString
.- Returns:
- A new instance of
JsonReader
. - Throws:
NullPointerException
- Ifjson
is null.IOException
- If aJsonReader
cannot be instantiated.
-
createReader
Creates an instance ofJsonReader
that reads aString
.- Parameters:
json
- The JSON represented as aString
.options
-JsonOptions
to configure the creation of theJsonReader
.- Returns:
- A new instance of
JsonReader
. - Throws:
NullPointerException
- Ifjson
oroptions
is null.IOException
- If aJsonReader
cannot be instantiated.
-
createReader
Creates an instance ofJsonReader
that reads aInputStream
.If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to
createReader(json, new JsonOptions())
.- Parameters:
json
- The JSON represented as aInputStream
.- Returns:
- A new instance of
JsonReader
. - Throws:
NullPointerException
- Ifjson
is null.IOException
- If aJsonReader
cannot be instantiated.
-
createReader
Creates an instance ofJsonReader
that reads aInputStream
.- Parameters:
json
- The JSON represented as aInputStream
.options
-JsonOptions
to configure the creation of theJsonReader
.- Returns:
- A new instance of
JsonReader
. - Throws:
NullPointerException
- Ifjson
oroptions
is null.IOException
- If aJsonReader
cannot be instantiated.
-
createReader
Creates an instance ofJsonReader
that reads aReader
.If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to
createReader(json, new JsonOptions())
.- Parameters:
json
- The JSON represented as aReader
.- Returns:
- A new instance of
JsonReader
. - Throws:
NullPointerException
- Ifjson
is null.IOException
- If aJsonReader
cannot be instantiated.
-
createReader
Creates an instance ofJsonReader
that reads aReader
.- Parameters:
json
- The JSON represented as aReader
.options
-JsonOptions
to configure the creation of theJsonReader
.- Returns:
- A new instance of
JsonReader
. - Throws:
NullPointerException
- Ifjson
oroptions
is null.IOException
- If aJsonReader
cannot be instantiated.
-
createWriter
Creates an instance ofJsonWriter
that writes to anOutputStream
.If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to
createWriter(json, new JsonOptions())
.- Parameters:
json
- The JSON represented as anOutputStream
.- Returns:
- A new instance of
JsonWriter
. - Throws:
NullPointerException
- Ifjson
is null.IOException
- If aJsonWriter
cannot be instantiated.
-
createWriter
Creates an instance ofJsonWriter
that writes to anOutputStream
.- Parameters:
json
- The JSON represented as anOutputStream
.options
-JsonOptions
to configure the creation of theJsonWriter
.- Returns:
- A new instance of
JsonWriter
. - Throws:
NullPointerException
- Ifjson
oroptions
is null.IOException
- If aJsonWriter
cannot be instantiated.
-
createWriter
Creates an instance ofJsonWriter
that writes to anWriter
.If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to
createWriter(json, new JsonOptions())
.- Parameters:
json
- The JSON represented as anWriter
.- Returns:
- A new instance of
JsonWriter
. - Throws:
NullPointerException
- Ifjson
is null.IOException
- If aJsonWriter
cannot be instantiated.
-
createWriter
Creates an instance ofJsonWriter
that writes to anWriter
.- Parameters:
json
- The JSON represented as anWriter
.options
-JsonOptions
to configure the creation of theJsonWriter
.- Returns:
- A new instance of
JsonWriter
. - Throws:
NullPointerException
- Ifjson
oroptions
is null.IOException
- If aJsonWriter
cannot be instantiated.
-