Insanely huge initial commit

This commit is contained in:
2026-02-21 17:04:05 -08:00
parent 9cdd36191a
commit 613d75914a
22525 changed files with 4035207 additions and 0 deletions

View File

@@ -0,0 +1,129 @@
// CreateStringSettings
using System;
using UnityEngine;
namespace Leguar.TotalJSON {
/// <summary>
/// Settings that can be used to make output of creating JSON-formatted string different.
/// </summary>
public class CreateStringSettings {
private bool escapeForwardSlashes = false;
/// <summary>
/// Sets forward slashes to escaped or not. TotalJSON default is false since escaped forward slashes could cause problems if included to C# code.
/// However, if resulting JSON string is included to for example HTML or JavaScript, it is better to set forward slash escaping on.
/// </summary>
/// <value>
/// True to escape forward slashes ("\/"), false to not ("/").
/// </value>
public bool EscapeForwardSlashes {
set {
escapeForwardSlashes = value;
}
get {
return escapeForwardSlashes;
}
}
private bool humanReadable = false;
/// <summary>
/// Sets output to be more human readable. Linefeeds and indentations are added to output to make it easier for humans to read and edit.
/// Output is still completely valid JSON that can be parsed back to JSON or JArray object.
/// </summary>
/// <value>
/// True to make output human readable. Default is false.
/// </value>
public bool HumanReadable {
set {
humanReadable = value;
}
get {
return humanReadable;
}
}
private bool indentUsingTab = true;
/// <summary>
/// Sets whatever indent of human readable output should use tabs. If false, spaces are used instead of tab.
/// </summary>
/// <remarks>
/// This setting have effect only if 'HumanReadable' is true.
/// </remarks>
/// <value>
/// True to use tabs for indent. Default is true.
/// </value>
public bool IndentUsingTab {
set {
if (!humanReadable) {
Debug.LogWarning("CreateStringSettings.IndentUsingTab setting have no effect when CreateStringSettings.HumanReadable is false");
}
indentUsingTab = value;
}
get {
return indentUsingTab;
}
}
private int indentSpaceCount = 4;
/// <summary>
/// Sets how many spaces are used for indent. Can be 0 or any positive integer.
/// </summary>
/// <remarks>
/// This setting have effect only if 'HumanReadable' is true and 'IndentUsingTab' is false.
/// </remarks>
/// <value>
/// Amount of spaces to use for indent. Default is 4.
/// </value>
public int IndentSpaceCount {
set {
if (!humanReadable) {
Debug.LogWarning("CreateStringSettings.IndentSpaceCount setting have no effect when CreateStringSettings.HumanReadable is false");
} else if (indentUsingTab) {
Debug.LogWarning("CreateStringSettings.IndentSpaceCount setting have no effect when CreateStringSettings.IndentUsingTab is true");
}
indentSpaceCount = value;
}
get {
return indentSpaceCount;
}
}
public enum NewLineTypes {
EnvironmentDefault,
LF,
CR_LF
}
private NewLineTypes newLine = NewLineTypes.EnvironmentDefault;
/// <summary>
/// Sets type of linefeeds in human readable output.
/// </summary>
/// <remarks>
/// This setting have effect only if 'HumanReadable' is true.
/// </remarks>
/// <value>
/// Type of linefeeds, one of values from NewLineTypes. Default is EnvironmentDefault.
/// </value>
public NewLineTypes NewLine {
set {
if (!humanReadable) {
Debug.LogWarning("CreateStringSettings.NewLine setting have no effect when CreateStringSettings.HumanReadable is false");
}
newLine = value;
}
get {
return newLine;
}
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e51ce8bcbc9ee4c4db94a03f8c456c64
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,121 @@
// DeserializeSettings
namespace Leguar.TotalJSON {
/// <summary>
/// Settings for deserialization.
/// </summary>
public class DeserializeSettings {
private bool allowFieldsToBeObjects = false;
/// <summary>
/// By default this is false. Meaning that any fields where values are deserialized need to be exactly same type as JSON object. For example JBoolean goes only to
/// bool, JString goes only to string, JSON goes only to Dictionary etc.
///
/// If this is set true, deserialization allows target fields also to be just objects (System.Object). Note however that in some cases deserialization may need to
/// "guess" the correct type, for example if deserializing JNumber to object field ("10" can be either int, long, float or double).
/// </summary>
/// <value>
/// False by default, set true to allow more loose deserialization.
/// </value>
public bool AllowFieldsToBeObjects {
set {
allowFieldsToBeObjects = value;
}
get {
return allowFieldsToBeObjects;
}
}
private bool allowNonStringDictionaryKeys = false;
/// <summary>
/// By default this is false. Meaning that if any JSON object is deserialized to dictionary, target dictionary must be using string keys, like JSON itself is using.
///
/// If this is set true, dictionaries key type may also be integer or long. In this case deserialization try to change JSON keys to required dictionary key type.
/// Note however that this may cause several problems when deserializing. For example, JSON object may contain keys "1" and "01". Deserializing this to Dictionary
/// with string keys can be done without issues. But deserializing that JSON to Dictionary with integer keys causes error due duplicate key, even original JSON is
/// completely valid.
/// </summary>
/// <value>
/// False by default, set true to allow more loose and flexible deserialization to dictionaries.
/// </value>
public bool AllowNonStringDictionaryKeys {
set {
allowNonStringDictionaryKeys = value;
}
get {
return allowNonStringDictionaryKeys;
}
}
private bool ignoreSystemAndUnitySerializeAttributes = false;
/// <summary>
/// By default this is false. Meaning that deserialization will check fields for UnityEngine.SerializeField and System.NonSerialized attributes and follow those.
///
/// In case these attributes are required for other uses but JSON deserialization should not follow these attributes, you can set this setting to true and those
/// attributes will be ignored during JSON deserialization. You can still include/exclude single fields during deserialization using TotalJSON's own
/// IncludeToJSONSerialize and ExcludeFromJSONSerialize attributes which are always followed regardless of this setting.
/// </summary>
/// <value>
/// False by default, set true to ignore non-json specific serialization attributes.
/// </value>
public bool IgnoreSystemAndUnitySerializeAttributes {
set {
ignoreSystemAndUnitySerializeAttributes = value;
}
get {
return ignoreSystemAndUnitySerializeAttributes;
}
}
private bool requireAllFieldsArePopulated = true;
/// <summary>
/// Default is true, meaning all the public fields in class/struct where JSON is deserialized must get their value set. So source JSON must contain matching values
/// for all the fields.
///
/// If set to false, fields that have no matching data in JSON are just left in their default values.
///
/// For example, with default setting, deserializing JSON {"a":1,"b":2} to class { public int a; public int b; public int c; } will cause exception since there's
/// no value for field 'c'.
/// </summary>
/// <value>
/// True by default, set false to allow classes/structs not to get fully populated.
/// </value>
public bool RequireAllFieldsArePopulated {
set {
requireAllFieldsArePopulated = value;
}
get {
return requireAllFieldsArePopulated;
}
}
private bool requireAllJSONValuesAreUsed = false;
/// <summary>
/// Default is false, meaning that any possible extra values in source JSON are ignored. If set to true, it is strictly required that all the values from JSON must
/// get used to populate some field in target class/struct.
///
/// For example, with default setting, deserializing JSON {"a":1,"b":2,"c":3} to class { public int a; public int b; } is acceptable and JSON value for 'c' is just
/// not used.
/// </summary>
/// <value>
/// False by default, set true to require that everything in source JSON is used.
/// </value>
public bool RequireAllJSONValuesAreUsed {
set {
requireAllJSONValuesAreUsed = value;
}
get {
return requireAllJSONValuesAreUsed;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 75df3196b7ff7f146a45b3bea4f17153
timeCreated: 1575388796
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,95 @@
// ParseStringSettings
using System;
using UnityEngine;
namespace Leguar.TotalJSON {
/// <summary>
/// Settings that can be used to make changes how string is parsed to JSON or JArray.
/// </summary>
public class ParseStringSettings {
private bool fixRoundedFloatingPointMinMaxValues = true;
/// <summary>
/// If set true, numeric values that seem to be just rounded float.MinValue, float.MaxValue, double.MinValue or double.MaxValue are set to those exact values.
///
/// C# floating point numbers rounding sometimes causes unwanted effects. In some systems, for example double.Parse(double.MaxValue.ToString()) will cause number overflow exception.
/// TotalJSON will use exact values when creating JSON formatted string using CreateString() method. But if JSON is created using other methods and it is possible JSON may contain
/// rounded floating point min/max values, it is better to set this setting true so that parsed values are what they are expected to be.
/// </summary>
/// <value>
/// True to fix rounded floating point values to float/double min/max values. False to parse numbers exactly as they are. Default is true.
/// </value>
public bool FixRoundedFloatingPointMinMaxValues {
set {
fixRoundedFloatingPointMinMaxValues = value;
}
get {
return fixRoundedFloatingPointMinMaxValues;
}
}
private int parseStartIndex = 0;
/// <summary>
/// Sets index of input string where parsing JSON or JArray object is started.
/// </summary>
/// <value>
/// The index of the parse start. Default is 0.
/// </value>
public int ParseStartIndex {
set {
parseStartIndex = value;
}
get {
return parseStartIndex;
}
}
private bool allowNonWhiteCharactersAfterObject = false;
/// <summary>
/// Sets whatever it is acceptable for input string to have other than non-white characters after end of JSON or JArray object.
/// </summary>
/// <value>
/// If set to true, non-white characters are accepted at end of object. Default is false, so expecting that input string ends at the end of JSON or JArray object.
/// </value>
public bool AllowNonWhiteCharactersAfterObject {
set {
allowNonWhiteCharactersAfterObject = value;
}
get {
return allowNonWhiteCharactersAfterObject;
}
}
private string debugIDForExceptions = null;
/// <summary>
/// Sets debug ID for this string parse and resulting JSON object. If any exception occurres during parsing or JSON handling after
/// succesful parse, this debug ID will be added to exception message.
///
/// This is typically useful in production builds where only exception message is logged but full stacktrace may not be available.
/// Typical parse error could be that source string is null or empty for some reason. Without adding this debug id to the parse,
/// exception is just "ParseException: Source string is empty" which isn't very helpful if project is parsing lots of incoming JSON
/// and so it is not clear which one causes this error. When adding this debug id to the parse, above exception would be for example
/// "ParseException: Source string is empty - Parse Debug ID: Backend own currency settings", which pinpoints the problem instantly.
/// </summary>
/// <value>
/// Debug ID. Default is null.
/// </value>
public string DebugIDForExceptions {
set {
debugIDForExceptions = value;
}
get {
return debugIDForExceptions;
}
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cef3164b1a677324f831ad8b0c509a49
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
// SerializeSettings
namespace Leguar.TotalJSON {
/// <summary>
/// Settings for serialization.
/// </summary>
public class SerializeSettings {
private bool allowNonStringDictionaryKeys = false;
/// <summary>
/// By default this is false. Meaning that if any dictionary is serialized to JSON object, source dictionary must be using string keys, like JSON itself is using.
///
/// If this is set false, dictionaries key type may be anything and serialization is just using ToString() to create key. In this case, make sure each dictionary
/// key string representation is unique.
/// </summary>
/// <value>
/// False by default, set true to allow any dictionary keys.
/// </value>
public bool AllowNonStringDictionaryKeys {
set {
allowNonStringDictionaryKeys = value;
}
get {
return allowNonStringDictionaryKeys;
}
}
private bool ignoreSystemAndUnitySerializeAttributes = false;
/// <summary>
/// By default this is false. Meaning that serialization will check fields for UnityEngine.SerializeField and System.NonSerialized attributes and follow those.
///
/// In case these attributes are required for other uses but JSON serialization should not follow these attributes, you can set this setting to true and those
/// attributes will be ignored during JSON serialization. You can still include/exclude single fields from serialization using TotalJSON's own
/// IncludeToJSONSerialize and ExcludeFromJSONSerialize attributes which are always followed regardless of this setting.
/// </summary>
/// <value>
/// False by default, set true to ignore non-json specific serialization attributes.
/// </value>
public bool IgnoreSystemAndUnitySerializeAttributes {
set {
ignoreSystemAndUnitySerializeAttributes = value;
}
get {
return ignoreSystemAndUnitySerializeAttributes;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a0a1c7d8f21e2f24bbf40192a47ff82a
timeCreated: 1575455464
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: