JsonProviders Class

  • java.lang.Object
    • com.azure.json.JsonProviders

public final class JsonProviders

Utility class for 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.

Method Summary

Modifier and Type Method and Description
static JsonReader createReader(byte[] json)

Creates an instance of JsonReader that reads a byte[].

static JsonReader createReader(byte[] json, JsonOptions options)

Creates an instance of JsonReader that reads a byte[].

static JsonReader createReader(InputStream json)

Creates an instance of JsonReader that reads a InputStream.

static JsonReader createReader(InputStream json, JsonOptions options)

Creates an instance of JsonReader that reads a InputStream.

static JsonReader createReader(Reader json)

Creates an instance of JsonReader that reads a Reader.

static JsonReader createReader(Reader json, JsonOptions options)

Creates an instance of JsonReader that reads a Reader.

static JsonReader createReader(String json)

Creates an instance of JsonReader that reads a String.

static JsonReader createReader(String json, JsonOptions options)

Creates an instance of JsonReader that reads a String.

static JsonWriter createWriter(OutputStream json)

Creates an instance of JsonWriter that writes to an OutputStream.

static JsonWriter createWriter(OutputStream json, JsonOptions options)

Creates an instance of JsonWriter that writes to an OutputStream.

static JsonWriter createWriter(Writer json)

Creates an instance of JsonWriter that writes to an Writer.

static JsonWriter createWriter(Writer json, JsonOptions options)

Creates an instance of JsonWriter that writes to an Writer.

Methods inherited from java.lang.Object

Method Details

createReader

public static JsonReader createReader(byte[] json)

Creates an instance of JsonReader that reads a byte[].

If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to createReader(byte[] json, JsonOptions options).

Parameters:

json - The JSON represented as a byte[].

Returns:

A new instance of JsonReader.

Throws:

IOException

- If json is null.

createReader

public static JsonReader createReader(byte[] json, JsonOptions options)

Creates an instance of JsonReader that reads a byte[].

Parameters:

json - The JSON represented as a byte[].
options - JsonOptions to configure the creation of the JsonReader.

Returns:

A new instance of JsonReader.

Throws:

IOException

- If json or options is null.

createReader

public static JsonReader createReader(InputStream json)

Creates an instance of JsonReader that reads a InputStream.

If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to createReader(InputStream json, JsonOptions options).

Parameters:

json - The JSON represented as a InputStream.

Returns:

A new instance of JsonReader.

Throws:

IOException

- If json is null.

createReader

public static JsonReader createReader(InputStream json, JsonOptions options)

Creates an instance of JsonReader that reads a InputStream.

Parameters:

json - The JSON represented as a InputStream.
options - JsonOptions to configure the creation of the JsonReader.

Returns:

A new instance of JsonReader.

Throws:

IOException

- If json or options is null.

createReader

public static JsonReader createReader(Reader json)

Creates an instance of JsonReader that reads a Reader.

If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to createReader(Reader json, JsonOptions options).

Parameters:

json - The JSON represented as a Reader.

Returns:

A new instance of JsonReader.

Throws:

IOException

- If json is null.

createReader

public static JsonReader createReader(Reader json, JsonOptions options)

Creates an instance of JsonReader that reads a Reader.

Parameters:

json - The JSON represented as a Reader.
options - JsonOptions to configure the creation of the JsonReader.

Returns:

A new instance of JsonReader.

Throws:

IOException

- If json or options is null.

createReader

public static JsonReader createReader(String json)

Creates an instance of JsonReader that reads a String.

If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to createReader(String json, JsonOptions options).

Parameters:

json - The JSON represented as a String.

Returns:

A new instance of JsonReader.

Throws:

IOException

- If json is null.

createReader

public static JsonReader createReader(String json, JsonOptions options)

Creates an instance of JsonReader that reads a String.

Parameters:

json - The JSON represented as a String.
options - JsonOptions to configure the creation of the JsonReader.

Returns:

A new instance of JsonReader.

Throws:

IOException

- If json or options is null.

createWriter

public static JsonWriter createWriter(OutputStream json)

Creates an instance of JsonWriter that writes to an OutputStream.

If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to createWriter(OutputStream json, JsonOptions options).

Parameters:

json - The JSON represented as an OutputStream.

Returns:

A new instance of JsonWriter.

Throws:

IOException

- If json is null.

createWriter

public static JsonWriter createWriter(OutputStream json, JsonOptions options)

Creates an instance of JsonWriter that writes to an OutputStream.

Parameters:

json - The JSON represented as an OutputStream.
options - JsonOptions to configure the creation of the JsonWriter.

Returns:

A new instance of JsonWriter.

Throws:

IOException

- If json or options is null.

createWriter

public static JsonWriter createWriter(Writer json)

Creates an instance of JsonWriter that writes to an Writer.

If a provider could not be found on the classpath this will use the default implementation, effectively the equivalent to createWriter(Writer json, JsonOptions options).

Parameters:

json - The JSON represented as an Writer.

Returns:

A new instance of JsonWriter.

Throws:

IOException

- If json is null.

createWriter

public static JsonWriter createWriter(Writer json, JsonOptions options)

Creates an instance of JsonWriter that writes to an Writer.

Parameters:

json - The JSON represented as an Writer.
options - JsonOptions to configure the creation of the JsonWriter.

Returns:

A new instance of JsonWriter.

Throws:

IOException

- If json or options is null.

Applies to