Class JsonVisitorAdapter | Serialization | 0.6.4-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Class JsonVisitorAdapter

    The JsonVisitorAdapter can be inherited to implement custom serializers for user-defined types.

    Inheritance
    Object
    JsonVisitorAdapter
    Namespace: Unity.Serialization.Json
    Syntax
    public abstract class JsonVisitorAdapter : IPropertyVisitorAdapter

    Constructors

    JsonVisitorAdapter(JsonVisitor)

    Initializes a new instance of JsonVisitorAdapter.

    Declaration
    protected JsonVisitorAdapter(JsonVisitor visitor)
    Parameters
    Type Name Description
    JsonVisitor visitor

    The JsonVisitor this adapter was added to.

    Methods

    Append<TProperty, TValue>(TProperty, TValue, Action<StringBuilder, TValue>)

    This method handles all of the json boilerplate for writing a property.

    The write callback will be invoked during this call and should be used to write the actual value.

    Declaration
    protected void Append<TProperty, TValue>(TProperty property, TValue value, Action<StringBuilder, TValue> write)
        where TProperty : IProperty
    Parameters
    Type Name Description
    TProperty property

    The property being written.

    TValue value

    The value being written.

    Action<StringBuilder, TValue> write

    Callback invoked to write the value in a strongly typed way.

    Type Parameters
    Name Description
    TProperty

    The property type.

    TValue

    The value type.

    AppendJsonString<TProperty>(TProperty, String)

    Utility method to write a json encoded string.

    Declaration
    protected void AppendJsonString<TProperty>(TProperty property, string value)
        where TProperty : IProperty
    Parameters
    Type Name Description
    TProperty property

    The property being written.

    String value

    The string to append.

    Type Parameters
    Name Description
    TProperty

    The property type.

    EncodeJsonString(String)

    Encodes the given string to be written as json. This will add any necessary escape characters.

    Declaration
    protected static string EncodeJsonString(string value)
    Parameters
    Type Name Description
    String value

    The string value to encode.

    Returns
    Type Description
    String

    The encoded string value.

    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