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 JsonReadercreateReader(byte[] json) Creates an instance ofJsonReaderthat reads abyte[].static JsonReadercreateReader(byte[] json, JsonOptions options) Creates an instance ofJsonReaderthat reads abyte[].static JsonReadercreateReader(InputStream json) Creates an instance ofJsonReaderthat reads aInputStream.static JsonReadercreateReader(InputStream json, JsonOptions options) Creates an instance ofJsonReaderthat reads aInputStream.static JsonReadercreateReader(Reader json) Creates an instance ofJsonReaderthat reads aReader.static JsonReadercreateReader(Reader json, JsonOptions options) Creates an instance ofJsonReaderthat reads aReader.static JsonReadercreateReader(String json) Creates an instance ofJsonReaderthat reads aString.static JsonReadercreateReader(String json, JsonOptions options) Creates an instance ofJsonReaderthat reads aString.static JsonWritercreateWriter(OutputStream json) Creates an instance ofJsonWriterthat writes to anOutputStream.static JsonWritercreateWriter(OutputStream json, JsonOptions options) Creates an instance ofJsonWriterthat writes to anOutputStream.static JsonWritercreateWriter(Writer json) Creates an instance ofJsonWriterthat writes to anWriter.static JsonWritercreateWriter(Writer json, JsonOptions options) Creates an instance ofJsonWriterthat writes to anWriter.
-
Method Details
-
createReader
Creates an instance ofJsonReaderthat 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- Ifjsonis null.IOException- If aJsonReadercannot be instantiated.
-
createReader
Creates an instance ofJsonReaderthat reads abyte[].- Parameters:
json- The JSON represented as abyte[].options-JsonOptionsto configure the creation of theJsonReader.- Returns:
- A new instance of
JsonReader. - Throws:
NullPointerException- Ifjsonoroptionsis null.IOException- If aJsonReadercannot be instantiated.
-
createReader
Creates an instance ofJsonReaderthat 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- Ifjsonis null.IOException- If aJsonReadercannot be instantiated.
-
createReader
Creates an instance ofJsonReaderthat reads aString.- Parameters:
json- The JSON represented as aString.options-JsonOptionsto configure the creation of theJsonReader.- Returns:
- A new instance of
JsonReader. - Throws:
NullPointerException- Ifjsonoroptionsis null.IOException- If aJsonReadercannot be instantiated.
-
createReader
Creates an instance ofJsonReaderthat 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- Ifjsonis null.IOException- If aJsonReadercannot be instantiated.
-
createReader
Creates an instance ofJsonReaderthat reads aInputStream.- Parameters:
json- The JSON represented as aInputStream.options-JsonOptionsto configure the creation of theJsonReader.- Returns:
- A new instance of
JsonReader. - Throws:
NullPointerException- Ifjsonoroptionsis null.IOException- If aJsonReadercannot be instantiated.
-
createReader
Creates an instance ofJsonReaderthat 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- Ifjsonis null.IOException- If aJsonReadercannot be instantiated.
-
createReader
Creates an instance ofJsonReaderthat reads aReader.- Parameters:
json- The JSON represented as aReader.options-JsonOptionsto configure the creation of theJsonReader.- Returns:
- A new instance of
JsonReader. - Throws:
NullPointerException- Ifjsonoroptionsis null.IOException- If aJsonReadercannot be instantiated.
-
createWriter
Creates an instance ofJsonWriterthat 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- Ifjsonis null.IOException- If aJsonWritercannot be instantiated.
-
createWriter
Creates an instance ofJsonWriterthat writes to anOutputStream.- Parameters:
json- The JSON represented as anOutputStream.options-JsonOptionsto configure the creation of theJsonWriter.- Returns:
- A new instance of
JsonWriter. - Throws:
NullPointerException- Ifjsonoroptionsis null.IOException- If aJsonWritercannot be instantiated.
-
createWriter
Creates an instance ofJsonWriterthat 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- Ifjsonis null.IOException- If aJsonWritercannot be instantiated.
-
createWriter
Creates an instance ofJsonWriterthat writes to anWriter.- Parameters:
json- The JSON represented as anWriter.options-JsonOptionsto configure the creation of theJsonWriter.- Returns:
- A new instance of
JsonWriter. - Throws:
NullPointerException- Ifjsonoroptionsis null.IOException- If aJsonWritercannot be instantiated.
-