Struct SerializedValueView
A view on top of the PackedBinaryStream that represents any value.
Inherited Members
Namespace: Unity.Serialization.Json
Syntax
public readonly struct SerializedValueView : ISerializedView
Properties
Item[String]
Gets the value associated with the specified key.
Declaration
[BurstDiscard]
public readonly SerializedValueView this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
String | name | The key of the value to get. |
Property Value
Type | Description |
---|---|
SerializedValueView |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The view does not represent an object type. |
KeyNotFoundException | The key does not exist in the collection. |
Item[in FixedString128Bytes]
Gets the value associated with the specified key.
Declaration
public readonly SerializedValueView this[in FixedString128Bytes name] { get; }
Parameters
Type | Name | Description |
---|---|---|
FixedString128Bytes | name | The key of the value to get. |
Property Value
Type | Description |
---|---|
SerializedValueView |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The view does not represent an object type. |
KeyNotFoundException | The key does not exist in the collection. |
Item[in FixedString32Bytes]
Gets the value associated with the specified key.
Declaration
public readonly SerializedValueView this[in FixedString32Bytes name] { get; }
Parameters
Type | Name | Description |
---|---|---|
FixedString32Bytes | name | The key of the value to get. |
Property Value
Type | Description |
---|---|
SerializedValueView |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The view does not represent an object type. |
KeyNotFoundException | The key does not exist in the collection. |
Item[in FixedString64Bytes]
Gets the value associated with the specified key.
Declaration
public readonly SerializedValueView this[in FixedString64Bytes name] { get; }
Parameters
Type | Name | Description |
---|---|---|
FixedString64Bytes | name | The key of the value to get. |
Property Value
Type | Description |
---|---|
SerializedValueView |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The view does not represent an object type. |
KeyNotFoundException | The key does not exist in the collection. |
Type
The TokenType for this view. Use this to check which conversions are valid.
Declaration
public readonly TokenType Type { get; }
Property Value
Type | Description |
---|---|
TokenType |
Methods
AsArrayView()
Reinterprets the value as an array.
Declaration
public readonly SerializedArrayView AsArrayView()
Returns
Type | Description |
---|---|
SerializedArrayView | The value as a SerializedArrayView. |
AsBoolean()
Reinterprets the value as a bool.
Declaration
public readonly bool AsBoolean()
Returns
Type | Description |
---|---|
Boolean | The value as a bool. |
AsDouble()
Reinterprets the value as a double.
Declaration
public readonly double AsDouble()
Returns
Type | Description |
---|---|
Double | The value as a double. |
AsFixedString<T>()
Returns the value as a string.
Declaration
public readonly T AsFixedString<T>()
where T : struct, INativeList<byte>, IUTF8Bytes
Returns
Type | Description |
---|---|
T | The value as a string. |
Type Parameters
Name | Description |
---|---|
T | The fixed string type. |
AsFloat()
Reinterprets the value as a float.
Declaration
public readonly float AsFloat()
Returns
Type | Description |
---|---|
Single | The value as a float. |
AsInt32()
Reinterprets the value as a int.
Declaration
public readonly int AsInt32()
Returns
Type | Description |
---|---|
Int32 | The value as an int. |
AsInt64()
Reinterprets the value as a long.
Declaration
public readonly long AsInt64()
Returns
Type | Description |
---|---|
Int64 | The value as a long. |
AsMemberView()
Reinterprets the value as a member.
Declaration
public readonly SerializedMemberView AsMemberView()
Returns
Type | Description |
---|---|
SerializedMemberView | The value as a SerializedMemberView. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The value could not be reinterpreted. |
AsNativeText(Allocator)
Returns the value as a string.
Declaration
public readonly NativeText AsNativeText(Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
Allocator | allocator | The allocator to use for the text. |
Returns
Type | Description |
---|---|
NativeText | The value as a string. |
AsObjectView()
Reinterprets the value as an object.
Declaration
public readonly SerializedObjectView AsObjectView()
Returns
Type | Description |
---|---|
SerializedObjectView | The value as a SerializedObjectView. |
AsPrimitiveView()
Reinterprets the value as a primitive.
Declaration
public readonly SerializedPrimitiveView AsPrimitiveView()
Returns
Type | Description |
---|---|
SerializedPrimitiveView | The value as a SerializedPrimitiveView. |
AsStringView()
Reinterprets the value as an string.
Declaration
public readonly SerializedStringView AsStringView()
Returns
Type | Description |
---|---|
SerializedStringView | The value as a SerializedStringView. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The value could not be reinterpreted. |
AsUInt64()
Reinterprets the value as a ulong.
Declaration
public readonly ulong AsUInt64()
Returns
Type | Description |
---|---|
UInt64 | The value as a ulong. |
AsUnsafeText(Allocator)
Returns the value as a string.
Declaration
public readonly UnsafeText AsUnsafeText(Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
Allocator | allocator | The allocator to use for the text. |
Returns
Type | Description |
---|---|
UnsafeText | The value as a string. |
GetValue(in String)
Gets the value associated with the specified key.
Declaration
public readonly SerializedValueView GetValue(in string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The key of the value to get. |
Returns
Type | Description |
---|---|
SerializedValueView | Returns the value associated with the specified key. |
GetValue<T>(in T)
Gets the value associated with the specified key.
Declaration
public readonly SerializedValueView GetValue<T>(in T name)
where T : struct, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
T | name | The key of the value to get. |
Returns
Type | Description |
---|---|
SerializedValueView | Returns the value associated with the specified key. |
Type Parameters
Name | Description |
---|---|
T | The fixed string type. |
IsMember()
Returns true if the value represents a member.
Declaration
public readonly bool IsMember()
Returns
Type | Description |
---|---|
Boolean | True if the value is a member. |
IsNull()
Returns true if the value represents a null value token.
Declaration
public readonly bool IsNull()
Returns
Type | Description |
---|---|
Boolean | true if the value represents a null value token. |
ToString()
Returns the value as a string.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
String | The value as a string. |
Overrides
TryGetValue(in String, out SerializedValueView)
Gets the value associated with the specified key.
Declaration
public readonly bool TryGetValue(in string name, out SerializedValueView value)
Parameters
Type | Name | Description |
---|---|---|
String | name | The key of the value to get. |
SerializedValueView | value | When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value. |
Returns
Type | Description |
---|---|
Boolean | true if the SerializedObjectView contains an element with the specified key; otherwise, false. |
TryGetValue<T>(in T, out SerializedValueView)
Gets the value associated with the specified key.
Declaration
public readonly bool TryGetValue<T>(in T name, out SerializedValueView value)
where T : struct, INativeList<byte>, IUTF8Bytes
Parameters
Type | Name | Description |
---|---|---|
T | name | The key of the value to get. |
SerializedValueView | value | When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value. |
Returns
Type | Description |
---|---|
Boolean | true if the SerializedObjectView contains an element with the specified key; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T | The fixed string type. |