Struct JsonObject
A JSON object.
Implements
Inherited Members
Namespace: SlugBase
Assembly: SlugBase.dll
Syntax
public readonly struct JsonObject : IEnumerable<KeyValuePair<string, JsonAny>>, IEnumerable
Properties
Item[String]
Get an element from this object.
Declaration
public readonly JsonAny this[string key] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.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
Get(String)
Get an element from this object.
Declaration
public readonly JsonAny Get(string key)
Parameters
Type | Name | Description |
---|---|---|
System.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 System.Boolean from this object.
Declaration
public readonly bool GetBool(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
System.Boolean |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
GetDouble(String)
Get a System.Double from this object.
Declaration
public readonly double GetDouble(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
System.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 readonly IEnumerator<KeyValuePair<string, JsonAny>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, JsonAny>> |
GetFloat(String)
Get a System.Single from this object.
Declaration
public readonly float GetFloat(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
System.Single |
Exceptions
Type | Condition |
---|---|
JsonException | The specified property doesn't exist or was the wrong type. |
GetInt(String)
Get an System.Int32 from this object.
Declaration
public readonly int GetInt(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
System.Int32 |
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 readonly JsonList GetList(string key)
Parameters
Type | Name | Description |
---|---|---|
System.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 System.Int64 from this object.
Declaration
public readonly long GetLong(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
System.Int64 |
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 readonly JsonObject GetObject(string key)
Parameters
Type | Name | Description |
---|---|---|
System.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 System.String from this object.
Declaration
public readonly string GetString(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
System.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 readonly JsonAny? TryGet(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The JSON property to search for. |
Returns
Type | Description |
---|---|
System.Nullable<JsonAny> | The found value, or |
Operators
Implicit(JsonObject to JsonAny)
Get obj
as a JsonAny.
Declaration
public static implicit operator JsonAny(JsonObject obj)
Parameters
Type | Name | Description |
---|---|---|
JsonObject | obj |
Returns
Type | Description |
---|---|
JsonAny |
Explicit Interface Implementations
IEnumerable.GetEnumerator()
A JSON object.
Declaration
readonly IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |