Struct SerializedObjectReader | Serialization | 1.4.3-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Struct SerializedObjectReader

    The SerializedObjectReader is the high level API used to deserialize a stream of data.

    Namespace: Unity.Serialization.Json
    Syntax
    public struct SerializedObjectReader : IDisposable

    Constructors

    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.

    Methods

    DiscardCompleted()

    Discards completed data from the buffers.

    Declaration
    public void DiscardCompleted()

    Dispose()

    Releases all resources used by the SerializedObjectReader.

    Declaration
    public void Dispose()

    Read(NodeType)

    Reads the next node in the stream, respecting depth/scope.

    Declaration
    public NodeType Read(NodeType node = NodeType.BeginObject | NodeType.ObjectKey | NodeType.EndObject | NodeType.BeginArray | NodeType.EndArray | NodeType.String | NodeType.Primitive | NodeType.Comment | 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.

    Read(out SerializedValueView, NodeType)

    Reads the next node in the stream, respecting depth/scope.

    Declaration
    public NodeType Read(out SerializedValueView view, NodeType node = NodeType.BeginObject | NodeType.ObjectKey | NodeType.EndObject | NodeType.BeginArray | NodeType.EndArray | NodeType.String | NodeType.Primitive | NodeType.Comment | 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 elements of an array and writes views to the given buffer.

    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 elements of an array and writes views to the given buffer.

    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

    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.

    Reset()

    Resets the reader state for re-use.

    Declaration
    public void Reset()
    Remarks

    This method will not manipulate the input stream in any way.

    Step(NodeType)

    Advances the reader to the given node type, ignoring depth/scope.

    Declaration
    public NodeType Step(NodeType node = NodeType.BeginObject | NodeType.ObjectKey | NodeType.EndObject | NodeType.BeginArray | NodeType.EndArray | NodeType.String | NodeType.Primitive | NodeType.Comment | 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.BeginObject | NodeType.ObjectKey | NodeType.EndObject | NodeType.BeginArray | NodeType.EndArray | NodeType.String | NodeType.Primitive | NodeType.Comment | 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.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023