Table of Contents

Class Json5Loader

Namespace
Core.Loaders
Assembly
Core.dll

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
object
Json5Loader

Methods

GetBool(JObject, string, bool)

Get boolean value from JObject

public static bool GetBool(JObject obj, string key, bool defaultValue = false)

Parameters

obj JObject
key string
defaultValue bool

Returns

bool

GetColor32(JObject, string, Color32)

Convert Color array to Unity Color32

public static Color32 GetColor32(JObject obj, string key, Color32 defaultColor = default)

Parameters

obj JObject
key string
defaultColor Color32

Returns

Color32

GetDateEntries(JObject)

Get all date-based entries (keys that look like dates)

public static Dictionary<string, JObject> GetDateEntries(JObject obj)

Parameters

obj JObject

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

obj JObject
key string
defaultValue float

Returns

float

GetInt(JObject, string, int)

Get integer value from JObject

public static int GetInt(JObject obj, string key, int defaultValue = 0)

Parameters

obj JObject
key string
defaultValue int

Returns

int

GetIntArray(JObject, string)

Get array of integers from JObject

public static List<int> GetIntArray(JObject obj, string key)

Parameters

obj JObject
key string

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

obj JObject
prefix string

Returns

List<string>

GetObject(JObject, string)

Get nested object from JObject

public static JObject GetObject(JObject obj, string key)

Parameters

obj JObject
key string

Returns

JObject

GetString(JObject, string, string)

Get string value from JObject

public static string GetString(JObject obj, string key, string defaultValue = "")

Parameters

obj JObject
key string
defaultValue string

Returns

string

GetStringArray(JObject, string)

Get array of strings from JObject

public static List<string> GetStringArray(JObject obj, string key)

Parameters

obj JObject
key string

Returns

List<string>

HasKey(JObject, string)

Check if key exists in object

public static bool HasKey(JObject obj, string key)

Parameters

obj JObject
key string

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

y1 int
m1 int
d1 int
y2 int
m2 int
d2 int

Returns

bool

IsDateKey(string)

Check if a key looks like a date (e.g., "1444.11.11")

public static bool IsDateKey(string key)

Parameters

key string

Returns

bool

LoadJson5File(string)

Load and parse a JSON5 file

public static JObject LoadJson5File(string filePath)

Parameters

filePath string

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

dateStr string
year int
month int
day int

Returns

bool