Struct SerializedObjectReader
The SerializedObjectReader is the high level API used to deserialize a stream of data.
Inherited Members
Namespace: Unity.Serialization.Json
Syntax
public struct SerializedObjectReader : IDisposable
Constructors
SerializedObjectReader(Char*, Int32, PackedBinaryStream, SerializedObjectReaderConfiguration, Allocator)
Initializes a new instance of the SerializedObjectReader class based on the specified input buffer, output stream and configuration.
Declaration
public SerializedObjectReader(char *buffer, int length, PackedBinaryStream output, SerializedObjectReaderConfiguration configuration, Allocator label = Allocator.TempJob)
Parameters
Type | Name | Description |
---|---|---|
Char* | buffer | The pointer to the input buffer. |
Int32 | length | The input buffer length. |
PackedBinaryStream | output | The output stream. |
SerializedObjectReaderConfiguration | configuration | The configuration parameters to use for the reader. |
Allocator | label | The memory allocator label to use. |
SerializedObjectReader(Char*, Int32, SerializedObjectReaderConfiguration, Allocator)
Initializes a new instance of the SerializedObjectReader class based on the specified input buffer and configuration.
Declaration
public SerializedObjectReader(char *buffer, int length, SerializedObjectReaderConfiguration configuration, Allocator label = Allocator.TempJob)
Parameters
Type | Name | Description |
---|---|---|
Char* | buffer | The pointer to the input buffer. |
Int32 | length | The input buffer length. |
SerializedObjectReaderConfiguration | configuration | The configuration parameters to use for the reader. |
Allocator | label | The memory allocator label to use. |
SerializedObjectReader(Stream, Allocator, Boolean)
Initializes a new instance of the SerializedObjectReader class based on the specified input stream.
Declaration
public SerializedObjectReader(Stream input, Allocator label = Allocator.TempJob, bool leaveInputOpen = true)
Parameters
Type | Name | Description |
---|---|---|
Stream | input | The input stream. |
Allocator | label | The memory allocator label to use. |
Boolean | leaveInputOpen | True to leave the input stream open after the reader object is disposed; otherwise, false. |
SerializedObjectReader(Stream, PackedBinaryStream, Allocator, Boolean, Boolean)
Initializes a new instance of the SerializedObjectReader class based on the specified input stream and output stream.
Declaration
public SerializedObjectReader(Stream input, PackedBinaryStream output, Allocator label = Allocator.TempJob, bool leaveInputOpen = true, bool leaveOutputOpen = true)
Parameters
Type | Name | Description |
---|---|---|
Stream | input | The input stream. |
PackedBinaryStream | output | The output stream. |
Allocator | label | The memory allocator label to use. |
Boolean | leaveInputOpen | True to leave the input stream open after the reader object is disposed; otherwise, false. |
Boolean | leaveOutputOpen | True to leave the output stream open after the reader object is disposed; otherwise, false. |
SerializedObjectReader(Stream, PackedBinaryStream, SerializedObjectReaderConfiguration, Allocator, Boolean, Boolean)
Initializes a new instance of the SerializedObjectReader class based on the specified input stream, output stream and configuration.
Declaration
public SerializedObjectReader(Stream input, PackedBinaryStream output, SerializedObjectReaderConfiguration configuration, Allocator label = Allocator.TempJob, bool leaveInputOpen = true, bool leaveOutputOpen = true)
Parameters
Type | Name | Description |
---|---|---|
Stream | input | The input stream. |
PackedBinaryStream | output | The output stream. |
SerializedObjectReaderConfiguration | configuration | The configuration parameters to use for the reader. |
Allocator | label | The memory allocator label to use. |
Boolean | leaveInputOpen | True to leave the input stream open after the reader object is disposed; otherwise, false. |
Boolean | leaveOutputOpen | True to leave the output stream open after the reader object is disposed; otherwise, false. |
Exceptions
Type | Condition |
---|---|
ArgumentException | The configuration is invalid. |
SerializedObjectReader(Stream, SerializedObjectReaderConfiguration, Allocator, Boolean)
Initializes a new instance of the SerializedObjectReader class based on the specified input stream and configuration.
Declaration
public SerializedObjectReader(Stream input, SerializedObjectReaderConfiguration configuration, Allocator label = Allocator.TempJob, bool leaveInputOpen = true)
Parameters
Type | Name | Description |
---|---|---|
Stream | input | The input stream. |
SerializedObjectReaderConfiguration | configuration | The configuration parameters to use for the reader. |
Allocator | label | The memory allocator label to use. |
Boolean | leaveInputOpen | True to leave the input stream open after the reader object is disposed; otherwise, false. |
SerializedObjectReader(String, Allocator)
Initializes a new instance of the SerializedObjectReader class with the specified path.
Declaration
public SerializedObjectReader(string path, Allocator label = Allocator.TempJob)
Parameters
Type | Name | Description |
---|---|---|
String | path | A relative or absolute file path. |
Allocator | label | The memory allocator label to use. |
SerializedObjectReader(String, PackedBinaryStream, Allocator, Boolean)
Initializes a new instance of the SerializedObjectReader class with the specified path and output stream.
Declaration
public SerializedObjectReader(string path, PackedBinaryStream output, Allocator label = Allocator.TempJob, bool leaveOutputOpen = true)
Parameters
Type | Name | Description |
---|---|---|
String | path | A relative or absolute file path. |
PackedBinaryStream | output | The output stream. |
Allocator | label | The memory allocator label to use. |
Boolean | leaveOutputOpen | True to leave the stream open after the reader object is disposed; otherwise, false. |
SerializedObjectReader(String, PackedBinaryStream, SerializedObjectReaderConfiguration, Allocator, Boolean)
Initializes a new instance of the SerializedObjectReader class with the specified path, output stream and configuration.
Declaration
public SerializedObjectReader(string path, PackedBinaryStream output, SerializedObjectReaderConfiguration configuration, Allocator label = Allocator.TempJob, bool leaveOutputOpen = true)
Parameters
Type | Name | Description |
---|---|---|
String | path | A relative or absolute file path. |
PackedBinaryStream | output | The output stream. |
SerializedObjectReaderConfiguration | configuration | The configuration parameters to use for the reader. |
Allocator | label | The memory allocator label to use. |
Boolean | leaveOutputOpen | True to leave the output stream open after the reader object is disposed; otherwise, false. |
SerializedObjectReader(String, SerializedObjectReaderConfiguration, Allocator)
Initializes a new instance of the SerializedObjectReader class with the specified path and configuration.
Declaration
public SerializedObjectReader(string path, SerializedObjectReaderConfiguration configuration, Allocator label = Allocator.TempJob)
Parameters
Type | Name | Description |
---|---|---|
String | path | A relative or absolute file path. |
SerializedObjectReaderConfiguration | configuration | The configuration parameters to use for the reader. |
Allocator | label | The memory allocator label to use. |
SerializedObjectReader(PackedBinaryStream, SerializedObjectReaderConfiguration, Allocator)
Initializes a new instance of the SerializedObjectReader class based on the specified configuration.
Declaration
public SerializedObjectReader(PackedBinaryStream output, SerializedObjectReaderConfiguration configuration, Allocator label = Allocator.TempJob)
Parameters
Type | Name | Description |
---|---|---|
PackedBinaryStream | output | The output stream. |
SerializedObjectReaderConfiguration | configuration | The configuration parameters to use for the reader. |
Allocator | label | The memory allocator label to use. |
SerializedObjectReader(SerializedObjectReaderConfiguration, Allocator)
Initializes a new instance of the SerializedObjectReader class based on the specified configuration.
Declaration
public SerializedObjectReader(SerializedObjectReaderConfiguration configuration, Allocator label = Allocator.TempJob)
Parameters
Type | Name | Description |
---|---|---|
SerializedObjectReaderConfiguration | configuration | The configuration parameters to use for the reader. |
Allocator | label | The memory allocator label to use. |
Methods
CheckAndThrowInvalidJsonException()
Throws any invalid json exceptions generated from within a burst context.
Declaration
public void CheckAndThrowInvalidJsonException()
DiscardCompleted()
Discards completed data from the buffers.
Declaration
public void DiscardCompleted()
Dispose()
Releases all resources used by the SerializedObjectReader.
Declaration
public void Dispose()
Implements
Read(Char*, Int32)
Reads the specified data and returns a new SerializedValueView.
Declaration
public SerializedValueView Read(char *ptr, int length)
Parameters
Type | Name | Description |
---|---|---|
Char* | ptr | The char buffer. |
Int32 | length | The char buffer length. |
Returns
Type | Description |
---|---|
SerializedValueView | The view for the first node in the stream. |
Remarks
This will invalidate any generated views from this reader.
Read(NodeType)
Reads the next node in the stream, respecting depth/scope.
Declaration
public NodeType Read(NodeType node = NodeType.Any)
Parameters
Type | Name | Description |
---|---|---|
NodeType | node | The node type to stop at. |
Returns
Type | Description |
---|---|
NodeType | The node type that was read. |
Read(out SerializedValueView, NodeType)
Reads the next node in the stream, respecting depth/scope.
Declaration
public NodeType Read(out SerializedValueView view, NodeType node = NodeType.Any)
Parameters
Type | Name | Description |
---|---|---|
SerializedValueView | view | The view at the returned node type. |
NodeType | node | The node type to stop at. |
Returns
Type | Description |
---|---|
NodeType | The node type the parser stopped at. |
ReadArrayElement(out SerializedValueView)
Reads the next node as an array element.
Declaration
public bool ReadArrayElement(out SerializedValueView view)
Parameters
Type | Name | Description |
---|---|---|
SerializedValueView | view | The view of the array element. |
Returns
Type | Description |
---|---|
Boolean | True if the element was successfully read, false otherwise. |
ReadArrayElementBatch(NativeArray<SerializedValueView>, Int32)
Reads the next
Declaration
public int ReadArrayElementBatch(NativeArray<SerializedValueView> views, int count)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<SerializedValueView> | views | The array to write the views to. |
Int32 | count | The number of elements to read. |
Returns
Type | Description |
---|---|
Int32 | The number of elements read. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | The count exceeded the array of views. |
ReadArrayElementBatch(SerializedValueView*, Int32)
Reads the next
Declaration
public int ReadArrayElementBatch(SerializedValueView*views, int count)
Parameters
Type | Name | Description |
---|---|---|
SerializedValueView* | views | The buffer to write the views to. |
Int32 | count | The number of elements to read. |
Returns
Type | Description |
---|---|
Int32 | The number of elements read. |
ReadMember()
Reads the next node as a SerializedMemberView.
Declaration
public SerializedMemberView ReadMember()
Returns
Type | Description |
---|---|
SerializedMemberView |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The reader state is invalid. |
ReadMember(SerializedMemberViewCollection)
Reads the next node as a member, respecting depth/scope and adds it to the given SerializedMemberViewCollection.
Declaration
public void ReadMember(SerializedMemberViewCollection collection)
Parameters
Type | Name | Description |
---|---|---|
SerializedMemberViewCollection | collection | The collection to add the member to. |
ReadObject()
Reads the next node as a SerializedObjectView
Declaration
public SerializedObjectView ReadObject()
Returns
Type | Description |
---|---|
SerializedObjectView | The SerializedObjectView that was read. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The reader state is invalid. |
Reset()
Resets the reader for re-use.
Declaration
public void Reset()
SetSource(Char*, Int32)
Sets the data source for the reader.
Declaration
public void SetSource(char *ptr, int length)
Parameters
Type | Name | Description |
---|---|---|
Char* | ptr | The char buffer. |
Int32 | length | The char buffer length. |
Remarks
This will invalidate any generated views from this reader.
Step(NodeType)
Advances the reader to the given node type, ignoring depth/scope.
Declaration
public NodeType Step(NodeType node = NodeType.Any)
Parameters
Type | Name | Description |
---|---|---|
NodeType | node | The node type to stop at. |
Returns
Type | Description |
---|---|
NodeType | The node type the parser stopped at. |
Step(out SerializedValueView, NodeType)
Advances the reader to the given node type, ignoring depth/scope.
Declaration
public NodeType Step(out SerializedValueView view, NodeType node = NodeType.Any)
Parameters
Type | Name | Description |
---|---|---|
SerializedValueView | view | The view at the returned node type. |
NodeType | node | The node type to stop at. |
Returns
Type | Description |
---|---|
NodeType | The node type the parser stopped at. |