Class JsonVisitor | Package Manager UI website
docs.unity.cn
    Show / Hide Table of Contents

    Class JsonVisitor

    A visitor that traverses a property container and outputs a JSON string.

    You can enrich the serialization by

    • Extend this class and overriding any methods.
    • Implement a JsonVisitorAdapter and register it using
    Inheritance
    System.Object
    JsonVisitor
    Namespace: Unity.Serialization.Json
    Syntax
    public class JsonVisitor : PropertyVisitor

    Constructors

    JsonVisitor()

    Initializes a new instance of JsonVisitor with the default adapters.

    Declaration
    public JsonVisitor()

    Properties

    Builder

    The inner string builder being written to.

    Declaration
    public StringBuilder Builder { get; }
    Property Value
    Type Description
    System.Text.StringBuilder

    Indent

    Gets or sets the current indent level.

    Declaration
    public int Indent { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    BeginCollection<TProperty, TContainer, TValue>(TProperty, ref TContainer, ref TValue, ref ChangeTracker)

    Invoked before visiting a collection type.

    Declaration
    protected override VisitStatus BeginCollection<TProperty, TContainer, TValue>(TProperty property, ref TContainer container, ref TValue value, ref ChangeTracker changeTracker)
    Parameters
    Type Name Description
    TProperty property

    The property being visited.

    TContainer container

    The container/host being visited.

    TValue value

    The value being visited.

    ChangeTracker changeTracker

    The change tracker for change propagation.

    Returns
    Type Description
    VisitStatus
    Type Parameters
    Name Description
    TProperty

    The property type.

    TContainer

    The container type.

    TValue

    The value type.

    BeginContainer<TProperty, TContainer, TValue>(TProperty, ref TContainer, ref TValue, ref ChangeTracker)

    Invoked before visiting a container type.

    Declaration
    protected override VisitStatus BeginContainer<TProperty, TContainer, TValue>(TProperty property, ref TContainer container, ref TValue value, ref ChangeTracker changeTracker)
    Parameters
    Type Name Description
    TProperty property

    The property being visited.

    TContainer container

    The container/host being visited.

    TValue value

    The value being visited.

    ChangeTracker changeTracker

    The change tracker for change propagation.

    Returns
    Type Description
    VisitStatus

    The result of the visit.

    Type Parameters
    Name Description
    TProperty

    The property type.

    TContainer

    The container type.

    TValue

    The value type.

    EndCollection<TProperty, TContainer, TValue>(TProperty, ref TContainer, ref TValue, ref ChangeTracker)

    Invoked after visiting a collection type.

    Declaration
    protected override void EndCollection<TProperty, TContainer, TValue>(TProperty property, ref TContainer container, ref TValue value, ref ChangeTracker changeTracker)
    Parameters
    Type Name Description
    TProperty property

    The property being visited.

    TContainer container

    The container/host being visited.

    TValue value

    The value being visited.

    ChangeTracker changeTracker

    The change tracker for change propagation.

    Type Parameters
    Name Description
    TProperty

    The property type.

    TContainer

    The container type.

    TValue

    The value type.

    EndContainer<TProperty, TContainer, TValue>(TProperty, ref TContainer, ref TValue, ref ChangeTracker)

    Invoked after visiting a container type.

    Declaration
    protected override void EndContainer<TProperty, TContainer, TValue>(TProperty property, ref TContainer container, ref TValue value, ref ChangeTracker changeTracker)
    Parameters
    Type Name Description
    TProperty property

    The property being visited.

    TContainer container

    The container/host being visited.

    TValue value

    The value being visited.

    ChangeTracker changeTracker

    The change tracker for change propagation.

    Type Parameters
    Name Description
    TProperty

    The property type.

    TContainer

    The container type.

    TValue

    The value type.

    GetTypeInfo<TProperty, TContainer, TValue>(TProperty, ref TContainer, ref TValue)

    Override this method to provide your own type information in the serialized json.

    Declaration
    protected virtual string GetTypeInfo<TProperty, TContainer, TValue>(TProperty property, ref TContainer container, ref TValue value)
        where TProperty : IProperty<TContainer, TValue>
    Parameters
    Type Name Description
    TProperty property
    TContainer container
    TValue value
    Returns
    Type Description
    System.String

    The type identifier as a string.

    Type Parameters
    Name Description
    TProperty

    The property type.

    TContainer

    The container type.

    TValue

    The value type.

    Back to top Copyright © 2019 Unity Technologies
    Generated by DocFX