Struct JsonObject
A JSON object.
Inherited Members
Namespace: SlugBase
Assembly: SlugBase.dll
Syntax
public readonly struct JsonObject : IEnumerable<KeyValuePair<string, JsonAny>>, IEnumerable
Properties
View Sourcethis[string]
Get an element from this object.
Declaration
public JsonAny this[string key] { get; }
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Property Value
Type | Description |
---|---|
JsonAny | The found value. |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist. |
Methods
View SourceGet(string)
Get an element from this object.
Declaration
public JsonAny Get(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
JsonAny | The found value. |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist. |
GetBool(string)
Get a bool from this object.
Declaration
public bool GetBool(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
bool |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
GetDouble(string)
Get a double from this object.
Declaration
public double GetDouble(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
double |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
GetEnumerator()
Get an enumerator for all properties and values of this object.
Declaration
public IEnumerator<KeyValuePair<string, JsonAny>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<string, JsonAny>> |
GetFloat(string)
Get a float from this object.
Declaration
public float GetFloat(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
float |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
GetInt(string)
Get an int from this object.
Declaration
public int GetInt(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
int |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
GetList(string)
Get a JsonList from this object.
Declaration
public JsonList GetList(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
JsonList |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
GetLong(string)
Get a long from this object.
Declaration
public long GetLong(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
long |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
GetObject(string)
Get a JsonObject from this object.
Declaration
public JsonObject GetObject(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
JsonObject |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist. |
GetString(string)
Get a string from this object.
Declaration
public string GetString(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
string |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
TryGet(string)
Get an element from this object.
Declaration
public JsonAny? TryGet(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
JsonAny? | The found value, or |
Operators
View Sourceimplicit operator JsonAny(JsonObject)
Get obj
as a JsonAny.
Declaration
public static implicit operator JsonAny(JsonObject obj)
Parameters
Type | Name | Description |
---|---|---|
JsonObject | obj |
Returns
Type | Description |
---|---|
JsonAny |