Class JsonArrayUtility
Helper script for serializing and de-serializing Json Arrays Unity's built in Json Serializer is not able to handle JSON data which have an unnamed array at root level
Inheritance
object
JsonArrayUtility
Namespace: i5.Toolkit.Core.Utilities
Assembly: cs.temp.dll.dll
Syntax
public static class JsonArrayUtility
Methods
EncapsulateInWrapper(string)
Helper function to encapsulate a json string which has an unnamed json array at root level in such a way that it can be converted using FromJson()
Declaration
public static string EncapsulateInWrapper(string json)
Parameters
Type | Name | Description |
---|---|---|
string | json | The original json string |
Returns
Type | Description |
---|---|
string | The encapsulated json string which is now ready for json array de-serialization |
FromJson<T>(string)
Converts a string to an array of the provided type
Declaration
public static T[] FromJson<T>(string json)
Parameters
Type | Name | Description |
---|---|---|
string | json | The json string |
Returns
Type | Description |
---|---|
T[] | Converted array of type T |
Type Parameters
Name | Description |
---|---|
T | The array type to convert to |
ToJson<T>(T[], bool)
Converts an array of type T to a json string
Declaration
public static string ToJson<T>(T[] array, bool prettyPrint = false)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Array to conver to json data |
bool | prettyPrint | If true, the output will be printed in a way that is more human-readable |
Returns
Type | Description |
---|---|
string | Json string |
Type Parameters
Name | Description |
---|---|
T | The type of the array |