Struct Value
Read-only view over a single JSON value, used to traverse arbitrary JSON data.
Inherited Members
Namespace: Unity.Cloud.Gltfast.Objects
Assembly: Unity.Cloud.Gltfast.dll
Syntax
public readonly ref struct Value
Remarks
Except for Kind and TryGetValue<T>(out T), every member requires the
value to be of a particular ValueKind and throws an
InvalidOperationException otherwise, including for
Undefined. A Value is Undefined
when it stands for "no value at all": default, the result of a failed
TryGetValue(string, out Value), or RawValue of an
extras that is a JSON object. Check Kind before reading.
Properties
ArrayLength
The number of elements, when this value is a Array.
Declaration
public int ArrayLength { get; }
Property Value
| Type | Description |
|---|---|
| int |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | This value is not of kind Array. |
this[int]
Gets the array element at index.
Declaration
public Value this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based element index. |
Property Value
| Type | Description |
|---|---|
| Value | The element's value. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | This value is not of kind Array. |
| IndexOutOfRangeException |
|
this[string]
Gets the value of the object property named key.
Declaration
public Value this[string key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The property name. |
Property Value
| Type | Description |
|---|---|
| Value | The property's value. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | This value is not of kind Object. |
| KeyNotFoundException | No property named
|
Kind
The ValueKind of this value.
Declaration
public ValueKind Kind { get; }
Property Value
| Type | Description |
|---|---|
| ValueKind |
Methods
EnumerateObject()
Returns an enumerator over the properties of this object value.
Declaration
public Value.ObjectEnumerator EnumerateObject()
Returns
| Type | Description |
|---|---|
| Value.ObjectEnumerator | An enumerator yielding each Property. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | This value is not of kind Object. |
GetBoolean()
Gets this value as a boolean.
Declaration
public bool GetBoolean()
Returns
| Type | Description |
|---|---|
| bool | The boolean value. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
GetString()
Gets this value as a string.
Declaration
public string GetString()
Returns
| Type | Description |
|---|---|
| string | The string value, or |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
TryGetDouble(out double)
Tries to get this value as a double-precision floating point number.
Declaration
public bool TryGetDouble(out double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The resulting number, if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | This value is not of kind Number. |
TryGetInt64(out long)
Tries to get this value as a 64-bit signed integer.
Declaration
public bool TryGetInt64(out long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The resulting integer, if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | This value is not of kind Number. |
TryGetValue(string, out Value)
Tries to get the value of the object property named key.
Declaration
public bool TryGetValue(string key, out Value value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The property name. |
| Value | value | The resulting value, if the property exists. Of kind Undefined otherwise. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | This value is not of kind Object. |
TryGetValue<T>(out T)
Tries to deserialize this value to type T.
Declaration
public bool TryGetValue<T>(out T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The resulting value, if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | Desired target type. |