-
Notifications
You must be signed in to change notification settings - Fork 120
JSON Serializer
BTD Mod Helper contains ways to easily convert an object to a JSON string, and vice versa
for System.Object
SerializeJson<T>((T objectToSerialize, bool shouldIndent = true, bool ignoreNulls = false)
same as above but allows you to put in a JsonSerializerSettings
SerializeJson<T>(T objectToSerialize, JsonSerializerSettings serializerSettings, bool shouldIndent = true)
same as above, but this time instead of returning a string it logs it to a specified savePath
SaveToFile<T>(T jsonObject, string savePath, JsonSerializerSettings serializerSettings, bool shouldIndent = true, bool overwriteExisting = true)
for Il2CppSystem.Object
Il2CppSerializeJson<T>(T il2cppObject, bool shouldIndent = true)
does the above but instead of returning a string it logs it to a specified savePath
Il2CppSaveToFile<T>(T jsonObject, string savePath, bool shouldIndent = true, bool overwriteExisting = true)
you can also use Ninja Kiwi's own logger, using the Assets.Scripts.Utils.FileIOUtil
.
FileIOUtil.LogToFile("filepath.json", obj);
(this will log it to C:\Users\<username>\AppData\LocalLow\Ninja Kiwi\BloonsTD6
)
doing the opposite of serializing, converting an JSON string to an Object
note: NOT GUARANTEED to work for Il2CppSystem.Object
s that do not have a constructor or [Serializable]
attribute
DeserializeJson<T>(string text)
- uses Newtonsoft.Json
to deserialize non-Il2Cpp objects
LoadFromFile<T>(string filePath)
- same as above, but uses a file stored locally for input instead
Il2CppDeserializeJson<T>(string text)
- uses Unity's JSON Deserialization thingy to deserialize some Il2Cpp Objects. Only official supports MonoBehaviour
and ScriptableObject
subclasses as well as plain structs and classes.
Il2CppLoadFromFile<T>(string filePath)
- Il2Cpp version of LoadFromFile
AS OF 4/11/2023 NEW WIKI EDITS ARE BEING MAINTAINED AT https://gurrenm3.github.io/BTD-Mod-Helper/wiki
Join our Discord server: https://discord.gg/PBwGjDQ4vX