# LoadFromJson(string)

> Load a GraphicsStateCollection from the provided JSON-formatted string.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Rendering](/engine/6000.5/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public bool LoadFromJson(string json)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The JSON-formatted string that represents a serialized GraphicsStateCollection object.

### Returns

| Type                                                          | Description                                                      |
| ------------------------------------------------------------- | ---------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the collection was successfully loaded, false otherwise. |

### Remarks

The file extension of GraphicsStateCollection is \*.graphicsstate.

Additional Resources: [GraphicsStateCollection.SaveToFile](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/savetofile.md), [GraphicsStateCollection.LoadFromFile](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/loadfromfile.md).

```csharp
using System.IO;
using UnityEngine;
using UnityEngine.Rendering;

public class LoadFromJsonExample : MonoBehaviour
{
    public GraphicsStateCollection graphicsStateCollection;
    public string jsonFilePath;

    void Start()
    {
        graphicsStateCollection = new GraphicsStateCollection();
        string serializedJson = File.ReadAllText(jsonFilePath);
        if (graphicsStateCollection.LoadFromJson(serializedJson))
        {
            Debug.Log("graphicsStateCollection contains " + graphicsStateCollection.totalGraphicsStateCount + " graphics states.");
        }
    }
}
```

Additional Resources: [GraphicsStateCollection.SaveToFile](/engine/6000.5/script-reference/unityengine/rendering/graphicsstatecollection/savetofile.md).
