docs.unity3d.com
    Show / Hide Table of Contents

    Class JsonExtensions

    Provides methods for returning a list of element from a json file or write a list into a json file.

    Inheritance
    Object
    JsonExtensions
    Namespace: Global Namespace
    Syntax
    public static class JsonExtensions

    Methods

    FromJsonList<T>(String)

    Convert a json formated list into a c# list.

    Declaration
    public static List<T> FromJsonList<T>(string json)
    Parameters
    Type Name Description
    String json

    json string containing a list of elements.

    Returns
    Type Description
    List<T>

    The C# list containing elements coming from the json list.

    Type Parameters
    Name Description
    T

    Type of the element in the list.

    ListToJson<T>(List<T>, Boolean)

    Convert a c# list into a json list

    Declaration
    public static string ListToJson<T>(List<T> list, bool pretty = false)
    Parameters
    Type Name Description
    List<T> list

    C# list of elements

    Boolean pretty

    Make the json string human readable(true) or pack as much as possible(false).

    Returns
    Type Description
    String

    A json list containing elements coming from the C# list.

    Type Parameters
    Name Description
    T

    Type of the element in the list.

    Back to top
    Terms of use
    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