BGC Tools
|
A wrapper object that contains a valid JSON value. More...
Data Structures | |
class | JsonValueDebugView |
Public Member Functions | |
JsonValue (bool? value) | |
Initializes a new instance of the JsonValue struct, representing a Boolean value. More... | |
JsonValue (double? value) | |
Initializes a new instance of the JsonValue struct, representing a Number value. More... | |
JsonValue (string value) | |
Initializes a new instance of the JsonValue struct, representing a String value. More... | |
JsonValue (JsonObject value) | |
Initializes a new instance of the JsonValue struct, representing a JsonObject. More... | |
JsonValue (JsonArray value) | |
Initializes a new instance of the JsonValue struct, representing a Array reference value. More... | |
override bool | Equals (object obj) |
Returns a value indicating whether this JsonValue is equal to the given object. More... | |
override int | GetHashCode () |
Returns a hash code for this JsonValue. More... | |
override string | ToString () |
Returns a JSON string representing the state of the object. More... | |
string | ToString (bool pretty) |
Returns a JSON string representing the state of the object. More... | |
Static Public Member Functions | |
static implicit | operator JsonValue (bool? value) |
Converts the given nullable boolean into a JsonValue. More... | |
static implicit | operator JsonValue (double? value) |
Converts the given nullable double into a JsonValue. More... | |
static implicit | operator JsonValue (string value) |
Converts the given string into a JsonValue. More... | |
static implicit | operator JsonValue (JsonObject value) |
Converts the given JsonObject into a JsonValue. More... | |
static implicit | operator JsonValue (JsonArray value) |
Converts the given JsonArray into a JsonValue. More... | |
static implicit | operator JsonValue (DateTime? value) |
Converts the given DateTime? into a JsonValue. More... | |
static implicit | operator int (JsonValue jsonValue) |
Converts the given JsonValue into an Int. More... | |
static implicit | operator int? (JsonValue jsonValue) |
Converts the given JsonValue into a nullable Int. More... | |
static implicit | operator bool (JsonValue jsonValue) |
Converts the given JsonValue into a Bool. More... | |
static implicit | operator bool? (JsonValue jsonValue) |
Converts the given JsonValue into a nullable Bool. More... | |
static implicit | operator double (JsonValue jsonValue) |
Converts the given JsonValue into a Double. More... | |
static implicit | operator double? (JsonValue jsonValue) |
Converts the given JsonValue into a nullable Double. More... | |
static implicit | operator string (JsonValue jsonValue) |
Converts the given JsonValue into a String. More... | |
static implicit | operator JsonObject (JsonValue jsonValue) |
Converts the given JsonValue into a JsonObject. More... | |
static implicit | operator JsonArray (JsonValue jsonValue) |
Converts the given JsonValue into a JsonArray. More... | |
static implicit | operator DateTime (JsonValue jsonValue) |
Converts the given JsonValue into a DateTime. More... | |
static implicit | operator DateTime? (JsonValue jsonValue) |
Converts the given JsonValue into a nullable DateTime. More... | |
static bool | operator== (JsonValue a, JsonValue b) |
Returns a value indicating whether the two given JsonValues are equal. More... | |
static bool | operator!= (JsonValue a, JsonValue b) |
Returns a value indicating whether the two given JsonValues are unequal. More... | |
static JsonValue | Parse (string text) |
Returns a JsonValue by parsing the given string. More... | |
Data Fields | |
JsonValueType | Type => type |
The type of this JsonValue. More... | |
bool | IsNull => Type == JsonValueType.Null |
Indicates whether this JsonValue is Null. More... | |
bool | IsBoolean => Type == JsonValueType.Boolean |
Indicates whether this JsonValue is a Boolean. More... | |
bool | IsNumber => Type == JsonValueType.Number |
Indicates whether this JsonValue is a Number. More... | |
bool | IsString => Type == JsonValueType.String |
Indicates whether this JsonValue is a String. More... | |
bool | IsJsonObject => Type == JsonValueType.Object |
Indicates whether this JsonValue is a JsonObject. More... | |
bool | IsJsonArray => Type == JsonValueType.Array |
Indicates whether this JsonValue is a JsonArray. More... | |
bool | IsDateTime => AsDateTime != null |
Indicates whether this JsonValue represents a DateTime. More... | |
JsonObject | AsJsonObject => IsJsonObject ? (JsonObject)reference : null |
This value as an JsonObject. More... | |
JsonArray | AsJsonArray => IsJsonArray ? (JsonArray)reference : null |
This value as an JsonArray. More... | |
Static Public Attributes | |
static readonly JsonValue | Null = new JsonValue(JsonValueType.Null, default(double), null) |
Represents a null JsonValue. More... | |
Properties | |
bool | IsInteger [get] |
Indicates whether this JsonValue is an Integer. More... | |
bool | AsBoolean [get] |
This value as a Boolean type. More... | |
int | AsInteger [get] |
This value as an Integer type. More... | |
double | AsNumber [get] |
This value as a Number type. More... | |
string | AsString [get] |
This value as a String type. More... | |
DateTime | AsDateTime [get] |
This value as a System.DateTime. More... | |
object | AsObject [get] |
This (inner) value as a System.object. More... | |
JsonValue | this[string key] [get, set] |
The value associated with the specified key. More... | |
JsonValue | this[int index] [get, set] |
The value at the specified index. More... | |
Private Member Functions | |
JsonValue (JsonValueType type, double value, object reference) | |
Initializes a new instance of the JsonValue struct. More... | |
Private Attributes | |
readonly JsonValueType | type |
readonly object | reference |
readonly double | value |
A wrapper object that contains a valid JSON value.
Definition at line 13 of file JsonValue.cs.
|
inlineprivate |
Initializes a new instance of the JsonValue struct.
type | The Json type of the JsonValue. |
value | The internal value of the JsonValue. This is used when the Json type is Number or Boolean. |
reference | The internal value reference of the JsonValue. This value is used when the Json type is String, JsonObject, or JsonArray. |
Definition at line 261 of file JsonValue.cs.
References LightJson.JsonValue.reference, LightJson.JsonValue.type, and LightJson.JsonValue.value.
Referenced by LightJson.JsonValue.JsonValue().
|
inline |
Initializes a new instance of the JsonValue struct, representing a Boolean value.
value | The value to be wrapped. |
Definition at line 272 of file JsonValue.cs.
References LightJson.JsonValue.Null.
|
inline |
Initializes a new instance of the JsonValue struct, representing a Number value.
value | The value to be wrapped. |
Definition at line 290 of file JsonValue.cs.
References LightJson.JsonValue.Null.
|
inline |
Initializes a new instance of the JsonValue struct, representing a String value.
value | The value to be wrapped. |
Definition at line 308 of file JsonValue.cs.
References LightJson.JsonValue.Null, and LightJson.JsonValue.value.
|
inline |
Initializes a new instance of the JsonValue struct, representing a JsonObject.
value | The value to be wrapped. |
Definition at line 326 of file JsonValue.cs.
References LightJson.JsonValue.Null, and LightJson.JsonValue.value.
|
inline |
Initializes a new instance of the JsonValue struct, representing a Array reference value.
value | The value to be wrapped. |
Definition at line 344 of file JsonValue.cs.
References LightJson.JsonValue.AsInteger, LightJson.JsonValue.IsBoolean, LightJson.JsonValue.IsInteger, LightJson.JsonValue.IsJsonArray, LightJson.JsonValue.IsJsonObject, LightJson.JsonValue.IsNull, LightJson.JsonValue.IsNumber, LightJson.JsonValue.IsString, LightJson.JsonValue.JsonValue(), LightJson.JsonValue.Null, LightJson.JsonValue.reference, and LightJson.JsonValue.value.
|
inline |
Returns a value indicating whether this JsonValue is equal to the given object.
obj | The object to test. |
Definition at line 531 of file JsonValue.cs.
References LightJson.JsonValue.IsNull.
Referenced by LightJson.JsonValue.operator==().
|
inline |
Returns a hash code for this JsonValue.
Definition at line 554 of file JsonValue.cs.
References LightJson.Serialization.JsonWriter.Serialize(), and LightJson.JsonValue.ToString().
|
static |
|
static |
|
inlinestatic |
Converts the given JsonValue into a DateTime.
jsonValue | The JsonValue to be converted. |
Definition at line 482 of file JsonValue.cs.
References LightJson.JsonValue.AsDateTime, LightJson.JsonValue.IsDateTime, and LightJson.JsonValue.IsNull.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Converts the given JsonValue into a JsonObject.
jsonValue | The JsonValue to be converted. |
|
static |
Converts the given nullable boolean into a JsonValue.
value | The value to be converted. |
|
static |
Converts the given nullable double into a JsonValue.
value | The value to be converted. |
|
static |
Converts the given string into a JsonValue.
value | The value to be converted. |
|
static |
Converts the given JsonObject into a JsonValue.
value | The value to be converted. |
|
static |
Converts the given DateTime? into a JsonValue.
The DateTime value will be stored as a string using ISO 8601 format, since JSON does not define a DateTime type.
value | The value to be converted. |
|
static |
Returns a value indicating whether the two given JsonValues are unequal.
Referenced by LightJson.JsonValue.operator==().
Returns a value indicating whether the two given JsonValues are equal.
Definition at line 507 of file JsonValue.cs.
References LightJson.JsonValue.Equals(), LightJson.JsonValue.operator!=(), LightJson.Serialization.JsonReader.Parse(), LightJson.JsonValue.Parse(), LightJson.JsonValue.reference, LightJson.JsonValue.Type, and LightJson.JsonValue.value.
|
static |
Returns a JsonValue by parsing the given string.
text | The JSON-formatted string to be parsed. |
Referenced by LightJson.JsonValue.operator==().
override string LightJson.JsonValue.ToString | ( | ) |
Returns a JSON string representing the state of the object.
The resulting string is safe to be inserted as is into dynamically generated JavaScript or JSON code.
Referenced by LightJson.JsonValue.GetHashCode().
string LightJson.JsonValue.ToString | ( | bool | pretty | ) |
Returns a JSON string representing the state of the object.
The resulting string is safe to be inserted as is into dynamically generated JavaScript or JSON code.
pretty | Indicates whether the resulting string should be formatted for human-readability. |
JsonArray LightJson.JsonValue.AsJsonArray => IsJsonArray ? (JsonArray)reference : null |
This value as an JsonArray.
Definition at line 155 of file JsonValue.cs.
Referenced by BGC.IO.ResourceInfo.InitializeResourceInfo().
JsonObject LightJson.JsonValue.AsJsonObject => IsJsonObject ? (JsonObject)reference : null |
This value as an JsonObject.
Definition at line 152 of file JsonValue.cs.
bool LightJson.JsonValue.IsBoolean => Type == JsonValueType.Boolean |
Indicates whether this JsonValue is a Boolean.
Definition at line 29 of file JsonValue.cs.
Referenced by BGC.Study.ProtocolManager.GetEnvBool(), and LightJson.JsonValue.JsonValue().
bool LightJson.JsonValue.IsDateTime => AsDateTime != null |
Indicates whether this JsonValue represents a DateTime.
Definition at line 61 of file JsonValue.cs.
Referenced by LightJson.JsonValue.operator DateTime().
bool LightJson.JsonValue.IsJsonArray => Type == JsonValueType.Array |
Indicates whether this JsonValue is a JsonArray.
Definition at line 58 of file JsonValue.cs.
Referenced by LightJson.JsonValue.JsonValue().
bool LightJson.JsonValue.IsJsonObject => Type == JsonValueType.Object |
Indicates whether this JsonValue is a JsonObject.
Definition at line 55 of file JsonValue.cs.
Referenced by LightJson.JsonValue.JsonValue().
bool LightJson.JsonValue.IsNull => Type == JsonValueType.Null |
Indicates whether this JsonValue is Null.
Definition at line 26 of file JsonValue.cs.
Referenced by LightJson.JsonObject.AddIfNotNull(), LightJson.JsonArray.AddIfNotNull(), LightJson.JsonValue.Equals(), LightJson.JsonArray.InsertIfNotNull(), LightJson.JsonValue.JsonValue(), and LightJson.JsonValue.operator DateTime().
bool LightJson.JsonValue.IsNumber => Type == JsonValueType.Number |
Indicates whether this JsonValue is a Number.
Definition at line 49 of file JsonValue.cs.
Referenced by BGC.Study.ProtocolManager.GetEnvFloat(), and LightJson.JsonValue.JsonValue().
bool LightJson.JsonValue.IsString => Type == JsonValueType.String |
Indicates whether this JsonValue is a String.
Definition at line 52 of file JsonValue.cs.
Referenced by BGC.Study.ProtocolManager.GetEnvStr(), and LightJson.JsonValue.JsonValue().
|
static |
Represents a null JsonValue.
Definition at line 20 of file JsonValue.cs.
Referenced by LightJson.JsonObject.JsonObject(), LightJson.JsonValue.JsonValue(), BGC.IO.FileReader.ReadJsonStream(), LightJson.Serialization.JsonReader.ReadNull(), and BGC.IO.FileReader.SafeReadJsonString().
|
private |
Definition at line 16 of file JsonValue.cs.
Referenced by LightJson.JsonValue.JsonValue(), and LightJson.JsonValue.operator==().
|
private |
Definition at line 15 of file JsonValue.cs.
Referenced by LightJson.JsonValue.JsonValue().
JsonValueType LightJson.JsonValue.Type => type |
The type of this JsonValue.
Definition at line 23 of file JsonValue.cs.
Referenced by LightJson.JsonValue.operator==(), LightJson.Serialization.JsonWriter.Render(), and LightJson.Serialization.JsonWriter.WriteEncodedJsonValue().
|
private |
Definition at line 17 of file JsonValue.cs.
Referenced by LightJson.JsonValue.JsonValue(), and LightJson.JsonValue.operator==().
|
get |
This value as a Boolean type.
Definition at line 65 of file JsonValue.cs.
Referenced by BGC.Study.ProtocolManager.GetEnvBool().
|
get |
This value as a System.DateTime.
Definition at line 159 of file JsonValue.cs.
Referenced by LightJson.JsonValue.operator DateTime().
|
get |
This value as an Integer type.
Definition at line 82 of file JsonValue.cs.
Referenced by BGC.DataStructures.IntListContainer.Deserialize(), BGC.Study.ProtocolManager.GetEnvBool(), BGC.Study.ProtocolManager.GetEnvInt(), BGC.Extensions.JsonExtensions.JsonArrayToIntList(), and LightJson.JsonValue.JsonValue().
|
get |
This value as a Number type.
Definition at line 104 of file JsonValue.cs.
Referenced by BGC.Study.ProtocolManager.GetEnvFloat().
|
get |
This (inner) value as a System.object.
Definition at line 175 of file JsonValue.cs.
|
get |
This value as a String type.
Definition at line 131 of file JsonValue.cs.
Referenced by BGC.Study.ProtocolManager.GetEnvStr(), and LightJson.Serialization.JsonWriter.WriteEncodedJsonValue().
|
get |
Indicates whether this JsonValue is an Integer.
Definition at line 33 of file JsonValue.cs.
Referenced by BGC.DataStructures.IntListContainer.Deserialize(), BGC.Study.ProtocolManager.GetEnvBool(), BGC.Study.ProtocolManager.GetEnvInt(), and LightJson.JsonValue.JsonValue().
|
getset |
The value at the specified index.
index | The zero-based index of the value to get or set. |
Definition at line 228 of file JsonValue.cs.
|
getset |
The value associated with the specified key.
key | The key of the value to get or set. |
InvalidOperationException | Thrown when this JsonValue is not a JsonObject. |
Definition at line 201 of file JsonValue.cs.