Class Json5Loader
Simple and reliable JSON5 loader to replace the broken ParadoxParser Handles JSON5 files converted from Paradox format with proper structure
public static class Json5Loader
- Inheritance
-
objectJson5Loader
Methods
GetBool(JObject, string, bool)
Get boolean value from JObject
public static bool GetBool(JObject obj, string key, bool defaultValue = false)
Parameters
objJObjectkeystringdefaultValuebool
Returns
- bool
GetColor32(JObject, string, Color32)
Convert Color array to Unity Color32
public static Color32 GetColor32(JObject obj, string key, Color32 defaultColor = default)
Parameters
objJObjectkeystringdefaultColorColor32
Returns
GetDateEntries(JObject)
Get all date-based entries (keys that look like dates)
public static Dictionary<string, JObject> GetDateEntries(JObject obj)
Parameters
objJObject
Returns
- Dictionary<string, JObject>
GetFloat(JObject, string, float)
Get float value from JObject
public static float GetFloat(JObject obj, string key, float defaultValue = 0)
Parameters
objJObjectkeystringdefaultValuefloat
Returns
- float
GetInt(JObject, string, int)
Get integer value from JObject
public static int GetInt(JObject obj, string key, int defaultValue = 0)
Parameters
objJObjectkeystringdefaultValueint
Returns
- int
GetIntArray(JObject, string)
Get array of integers from JObject
public static List<int> GetIntArray(JObject obj, string key)
Parameters
objJObjectkeystring
Returns
- List<int>
GetKeysStartingWith(JObject, string)
Get all keys that start with a prefix (useful for date entries)
public static List<string> GetKeysStartingWith(JObject obj, string prefix)
Parameters
objJObjectprefixstring
Returns
- List<string>
GetObject(JObject, string)
Get nested object from JObject
public static JObject GetObject(JObject obj, string key)
Parameters
objJObjectkeystring
Returns
- JObject
GetString(JObject, string, string)
Get string value from JObject
public static string GetString(JObject obj, string key, string defaultValue = "")
Parameters
objJObjectkeystringdefaultValuestring
Returns
- string
GetStringArray(JObject, string)
Get array of strings from JObject
public static List<string> GetStringArray(JObject obj, string key)
Parameters
objJObjectkeystring
Returns
- List<string>
HasKey(JObject, string)
Check if key exists in object
public static bool HasKey(JObject obj, string key)
Parameters
objJObjectkeystring
Returns
- bool
IsDateBeforeOrEqual(int, int, int, int, int, int)
Check if date1 is before or equal to date2
public static bool IsDateBeforeOrEqual(int y1, int m1, int d1, int y2, int m2, int d2)
Parameters
y1intm1intd1inty2intm2intd2int
Returns
- bool
IsDateKey(string)
Check if a key looks like a date (e.g., "1444.11.11")
public static bool IsDateKey(string key)
Parameters
keystring
Returns
- bool
LoadJson5File(string)
Load and parse a JSON5 file
public static JObject LoadJson5File(string filePath)
Parameters
filePathstring
Returns
- JObject
TryParseDate(string, out int, out int, out int)
Parse EU4 date format (Y.M.D like "1442.1.1")
public static bool TryParseDate(string dateStr, out int year, out int month, out int day)
Parameters
dateStrstringyearintmonthintdayint
Returns
- bool