Table of Contents

Class NewtonsoftJsonStructureSerializer

Namespace
NanoByte.StructureEditor.NewtonsoftJson
Assembly
NanoByte.StructureEditor.NewtonsoftJson.dll

Serializes nodes as JSON using Newtonsoft.Json.

public class NewtonsoftJsonStructureSerializer : IStructureSerializer
Inheritance
object
NewtonsoftJsonStructureSerializer
Implements

Constructors

NewtonsoftJsonStructureSerializer()

Creates a serializer with DefaultSettings.

public NewtonsoftJsonStructureSerializer()

NewtonsoftJsonStructureSerializer(JsonSerializerSettings)

Serializes nodes as JSON using Newtonsoft.Json.

public NewtonsoftJsonStructureSerializer(JsonSerializerSettings settings)

Parameters

settings JsonSerializerSettings

Settings for the serializer. Use DefaultSettings as a starting point for customization.

Properties

DefaultSettings

The default settings for the serializer: indented output.

public static JsonSerializerSettings DefaultSettings { get; }

Property Value

JsonSerializerSettings

FormatName

The name of the format (e.g., XML or JSON). Used to determine syntax highlighting.

public string FormatName { get; }

Property Value

string

Instance

A shared instance of the serializer using DefaultSettings.

public static NewtonsoftJsonStructureSerializer Instance { get; }

Property Value

NewtonsoftJsonStructureSerializer

Methods

Deserialize<T>(string)

Deserializes an object from a string.

public T Deserialize<T>(string text) where T : class

Parameters

text string

The serialized representation of the object.

Returns

T

Type Parameters

T

The type of object to deserialize.

Exceptions

Exception

The text is not a valid serialized representation of T.

Serialize<T>(T)

Serializes an object to a string.

public string Serialize<T>(T value) where T : class

Parameters

value T

The object to serialize.

Returns

string

Type Parameters

T

The type to serialize the object as.

TryGetErrorLocation(Exception, out int, out int, out string)

Extracts the location of an error from an exception thrown by Deserialize<T>(string).

public bool TryGetErrorLocation(Exception exception, out int line, out int column, out string message)

Parameters

exception Exception

The exception thrown by Deserialize<T>(string).

line int

The 1-based line number of the error.

column int

The 1-based column number of the error.

message string

A message describing the error.

Returns

bool

true if the location could be determined; false otherwise.