public class NewtonsoftJsonSerializer : object, IJsonSerializer, ISerializer
Class for serialization and deserialization of JSON documents using the Newtonsoft Library.
Namespace
Google.Apis.JsonAssembly
Google.Apis.Core.dll
Constructors
NewtonsoftJsonSerializer()
public NewtonsoftJsonSerializer()
Constructs a new instance with the default serialization settings, equivalent to Instance.
NewtonsoftJsonSerializer(JsonSerializerSettings)
public NewtonsoftJsonSerializer(JsonSerializerSettings settings)
Constructs a new instance with the given settings.
Parameter | |
---|---|
Name | Description |
settings | JsonSerializerSettings The settings to apply when serializing and deserializing. Must not be null. |
Properties
Format
public string Format { get; }
Gets the application format this serializer supports (e.g. "json", "xml", etc.).
Property Value | |
---|---|
Type | Description |
String |
Instance
public static NewtonsoftJsonSerializer Instance { get; }
The default instance of the Newtonsoft JSON Serializer, with default settings.
Property Value | |
---|---|
Type | Description |
NewtonsoftJsonSerializer |
Methods
CreateDefaultSettings()
public static JsonSerializerSettings CreateDefaultSettings()
Creates a new instance of with the same behavior as the ones used in Instance. This method is expected to be used to construct settings which are then passed to NewtonsoftJsonSerializer(JsonSerializerSettings).
Returns | |
---|---|
Type | Description |
JsonSerializerSettings | A new set of default settings. |
Deserialize(String, Type)
public object Deserialize(string input, Type type)
Deserializes the string into an object.
Parameters | |
---|---|
Name | Description |
input | String |
type | Type |
Returns | |
---|---|
Type | Description |
Object |
Deserialize<T>(Stream)
public T Deserialize<T>(Stream input)
Deserializes the stream into an object.
Parameter | |
---|---|
Name | Description |
input | Stream |
Returns | |
---|---|
Type | Description |
T |
Type Parameter | |
---|---|
Name | Description |
T |
Deserialize<T>(String)
public T Deserialize<T>(string input)
Deserializes the string into an object.
Parameter | |
---|---|
Name | Description |
input | String |
Returns | |
---|---|
Type | Description |
T |
Type Parameter | |
---|---|
Name | Description |
T |
DeserializeAsync<T>(Stream, CancellationToken)
public Task<T> DeserializeAsync<T>(Stream input, CancellationToken cancellationToken)
Deserializes the given stream but reads from it asynchronously, observing the given cancellation token. Note that this means the complete JSON is read before it is deserialized into objects.
Parameters | |
---|---|
Name | Description |
input | Stream The stream to read from. |
cancellationToken | CancellationToken Cancellation token for the operation. |
Returns | |
---|---|
Type | Description |
Task<T> | The deserialized object. |
Type Parameter | |
---|---|
Name | Description |
T | The type to convert to. |
Serialize(Object)
public string Serialize(object obj)
Serializes the specified object into a string.
Parameter | |
---|---|
Name | Description |
obj | Object |
Returns | |
---|---|
Type | Description |
String |
Serialize(Object, Stream)
public void Serialize(object obj, Stream target)
Serializes the specified object into a Stream.
Parameters | |
---|---|
Name | Description |
obj | Object |
target | Stream |