Table of Contents

Class JsonUtil

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll
public static class JsonUtil
Inheritance
JsonUtil
Inherited Members

Methods

CreateSerializerForDomain(string, JsonSerializerSettings)

public static JsonSerializer CreateSerializerForDomain(string domain, JsonSerializerSettings settings = null)

Parameters

domain string
settings JsonSerializerSettings

Returns

JsonSerializer

FromBytes<T>(byte[])

Reads a Json object, and converts it to the designated type.

public static T FromBytes<T>(byte[] data)

Parameters

data byte[]

The json object.

Returns

T

Type Parameters

T

The designated type

FromString<T>(string)

public static T FromString<T>(string data)

Parameters

data string

Returns

T

Type Parameters

T

PopulateObject(object, JToken, JsonSerializer)

public static void PopulateObject(object toPopulate, JToken token, JsonSerializer js)

Parameters

toPopulate object
token JToken
js JsonSerializer

PopulateObject(object, string, string, JsonSerializerSettings)

public static void PopulateObject(object toPopulate, string text, string domain, JsonSerializerSettings settings = null)

Parameters

toPopulate object
text string
domain string
settings JsonSerializerSettings

Populate<T>(JToken, T)

public static void Populate<T>(this JToken value, T target) where T : class

Parameters

value JToken
target T

Type Parameters

T

ToBytes<T>(T)

Converts the object to json.

public static byte[] ToBytes<T>(T obj)

Parameters

obj T

The object to convert

Returns

byte[]

Type Parameters

T

The type to convert

ToObject<T>(JToken, string, JsonSerializerSettings)

Converts a Json token to a typed object.

public static T ToObject<T>(this JToken token, string domain, JsonSerializerSettings settings = null)

Parameters

token JToken

The token to deserialize

domain string

The domain of the text.

settings JsonSerializerSettings

The settings of the deserializer. (default: Null)

Returns

T

Type Parameters

T

The type to convert.

ToObject<T>(string, string, JsonSerializerSettings)

Converts a Json object to a typed object.

public static T ToObject<T>(string text, string domain, JsonSerializerSettings settings = null)

Parameters

text string

The text to deserialize

domain string

The domain of the text.

settings JsonSerializerSettings

The settings of the deserializer. (default: Null)

Returns

T

Type Parameters

T

The type to convert.

ToPrettyString<T>(T)

public static string ToPrettyString<T>(T obj)

Parameters

obj T

Returns

string

Type Parameters

T

ToString<T>(T)

public static string ToString<T>(T obj)

Parameters

obj T

Returns

string

Type Parameters

T