Class GsonJsonProvider
java.lang.Object
com.azure.core.serializer.json.gson.GsonJsonProvider
- All Implemented Interfaces:
com.azure.json.JsonProvider
GSON-based implementation of
JsonProvider.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.azure.json.JsonReadercreateReader(byte[] json, com.azure.json.JsonOptions options) Creates an instance ofJsonReaderthat reads abyte[].com.azure.json.JsonReadercreateReader(com.google.gson.stream.JsonReader reader, com.azure.json.JsonOptions options) Creates an instance ofJsonReaderwrapping a GSONJsonReader.com.azure.json.JsonReadercreateReader(InputStream json, com.azure.json.JsonOptions options) Creates an instance ofJsonReaderthat reads aInputStream.com.azure.json.JsonReadercreateReader(Reader json, com.azure.json.JsonOptions options) Creates an instance ofJsonReaderthat reads aReader.com.azure.json.JsonReadercreateReader(String json, com.azure.json.JsonOptions options) Creates an instance ofJsonReaderthat reads aString.com.azure.json.JsonWritercreateWriter(com.google.gson.stream.JsonWriter writer) Creates an instance ofJsonWriterwrapping a GSONJsonWriter.com.azure.json.JsonWritercreateWriter(OutputStream json, com.azure.json.JsonOptions options) Creates an instance ofJsonWriterthat writes to anOutputStream.com.azure.json.JsonWritercreateWriter(Writer json, com.azure.json.JsonOptions options) Creates an instance ofJsonWriterthat writes to anWriter.static com.google.gson.TypeAdapterFactoryReturns a GSONTypeAdapterFactorythat allows forcom.azure.jsonimplementations to handle deserialization and serialization ofJsonSerializabletypes within a GSON context.
-
Constructor Details
-
GsonJsonProvider
public GsonJsonProvider()Creates an instance ofGsonJsonProvider.
-
-
Method Details
-
createReader
public com.azure.json.JsonReader createReader(byte[] json, com.azure.json.JsonOptions options) throws IOException Description copied from interface:com.azure.json.JsonProviderCreates an instance ofJsonReaderthat reads abyte[].- Specified by:
createReaderin interfacecom.azure.json.JsonProvider- Parameters:
json- The JSON represented as abyte[].options-JsonOptionsto configure the creation of theJsonReader.- Returns:
- A new instance of
JsonReader. - Throws:
IOException- If aJsonReadercannot be instantiated.
-
createReader
public com.azure.json.JsonReader createReader(String json, com.azure.json.JsonOptions options) throws IOException Description copied from interface:com.azure.json.JsonProviderCreates an instance ofJsonReaderthat reads aString.- Specified by:
createReaderin interfacecom.azure.json.JsonProvider- Parameters:
json- The JSON represented as aString.options-JsonOptionsto configure the creation of theJsonReader.- Returns:
- A new instance of
JsonReader. - Throws:
IOException- If aJsonReadercannot be instantiated.
-
createReader
public com.azure.json.JsonReader createReader(InputStream json, com.azure.json.JsonOptions options) throws IOException Description copied from interface:com.azure.json.JsonProviderCreates an instance ofJsonReaderthat reads aInputStream.- Specified by:
createReaderin interfacecom.azure.json.JsonProvider- Parameters:
json- The JSON represented as aInputStream.options-JsonOptionsto configure the creation of theJsonReader.- Returns:
- A new instance of
JsonReader. - Throws:
IOException- If aJsonReadercannot be instantiated.
-
createReader
public com.azure.json.JsonReader createReader(Reader json, com.azure.json.JsonOptions options) throws IOException Description copied from interface:com.azure.json.JsonProviderCreates an instance ofJsonReaderthat reads aReader.- Specified by:
createReaderin interfacecom.azure.json.JsonProvider- Parameters:
json- The JSON represented as aReader.options-JsonOptionsto configure the creation of theJsonReader.- Returns:
- A new instance of
JsonReader. - Throws:
IOException- If aJsonReadercannot be instantiated.
-
createReader
public com.azure.json.JsonReader createReader(com.google.gson.stream.JsonReader reader, com.azure.json.JsonOptions options) Creates an instance ofJsonReaderwrapping a GSONJsonReader.- Parameters:
reader- TheJsonReaderparsing JSON.options- The options used to create the reader.- Returns:
- A
JsonReaderwrapping theJsonReader. - Throws:
NullPointerException- Ifreaderis null.
-
createWriter
public com.azure.json.JsonWriter createWriter(OutputStream json, com.azure.json.JsonOptions options) throws IOException Description copied from interface:com.azure.json.JsonProviderCreates an instance ofJsonWriterthat writes to anOutputStream.- Specified by:
createWriterin interfacecom.azure.json.JsonProvider- Parameters:
json- The JSON represented as anOutputStream.options-JsonOptionsto configure the creation of theJsonWriter.- Returns:
- A new instance of
JsonWriter. - Throws:
IOException- If aJsonReadercannot be instantiated.
-
createWriter
public com.azure.json.JsonWriter createWriter(Writer json, com.azure.json.JsonOptions options) throws IOException Description copied from interface:com.azure.json.JsonProviderCreates an instance ofJsonWriterthat writes to anWriter.- Specified by:
createWriterin interfacecom.azure.json.JsonProvider- Parameters:
json- The JSON represented as anWriter.options-JsonOptionsto configure the creation of theJsonWriter.- Returns:
- A new instance of
JsonWriter. - Throws:
IOException- If aJsonReadercannot be instantiated.
-
createWriter
public com.azure.json.JsonWriter createWriter(com.google.gson.stream.JsonWriter writer) Creates an instance ofJsonWriterwrapping a GSONJsonWriter.- Parameters:
writer- TheJsonWriterwriting JSON.- Returns:
- A
JsonWriterwrapping theJsonWriter. - Throws:
NullPointerException- Ifwriteris null.
-
getJsonSerializableTypeAdapterFactory
public static com.google.gson.TypeAdapterFactory getJsonSerializableTypeAdapterFactory()Returns a GSONTypeAdapterFactorythat allows forcom.azure.jsonimplementations to handle deserialization and serialization ofJsonSerializabletypes within a GSON context.Use the
TypeAdapterFactoryreturned by this method when creating yourGsonwithGsonBuilderto have GSON supportJsonSerializabletypes.- Returns:
- A GSON
TypeAdapterFactorythat handles deserialization and serialization ofJsonSerializabletypes.
-