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
stringsettings
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
objecttoken
JTokenjs
JsonSerializer
PopulateObject(object, string, string, JsonSerializerSettings)
public static void PopulateObject(object toPopulate, string text, string domain, JsonSerializerSettings settings = null)
Parameters
Populate<T>(JToken, T)
public static void Populate<T>(this JToken value, T target) where T : class
Parameters
value
JTokentarget
T
Type Parameters
T
ToBytes<T>(T)
Converts the object to json.
public static byte[] ToBytes<T>(T obj)
Parameters
obj
TThe 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
JTokenThe token to deserialize
domain
stringThe domain of the text.
settings
JsonSerializerSettingsThe 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
stringThe text to deserialize
domain
stringThe domain of the text.
settings
JsonSerializerSettingsThe 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
Type Parameters
T
ToString<T>(T)
public static string ToString<T>(T obj)
Parameters
obj
T
Returns
Type Parameters
T