JsonUtility not serializing

I am having a issue serializing a json data where JsonUtility refuses to serialize a list of serializable classes. Below is what I got:

public class DialogueManager : MonoBehaviour {
    [SerializeField]
    public TextAsset jsonData;

    [SerializeField]
    DialogueContainer container;

    private void Start() {
        Debug.Log(jsonData.text);
        container = JsonUtility.FromJson<DialogueContainer>(jsonData.text);
        Debug.Log("Deserialization complete.");
    }
}

[System.Serializable]
public class DialogueContainer {
    public string language;
    public List<DialogueSet> dialogues;
}

[System.Serializable]
public class DialogueSet {
    public string memo;
    public string set;
    public List<DialogueCell> dialogue;
}

[System.Serializable]
public class DialogueCell {
    public string memo;
    public string text;
    public string speaker;
    public DialoguePortrait portrait;
    public List<DialogueOptions> options;
}

[System.Serializable]
public class DialoguePortrait {
    public string path;
    public int location;
    public bool orientation;
}

[System.Serializable]
public class DialogueOptions {
    public string text;
    public string jumpto;
}

and below is the json data I am trying to serialize

{
    "language": "en",
    "dialogue":[
        {
            "memo": "",
            "set": "chapter_1_section_1",
            "dialogue":
            [
                {
                    "memo": "",
                    "text": "test",
                    "speaker": "player",
                    "portrait":
                    {
                        "path": "",
                        "location": 0,
                        "orientation": true
                    },
                    "options":[
                        {
                            "text": "",
                            "jumpto": ""
                        }
                    ]
                }
            ]
        }
    ]
}

While accessing container.language returns "en" as expected, container.dialogues seems to return nothing. I have searched around for answers online and havent found a solution to why this is the cause. Any help would be appreciated.

Uhm, you may watch your spelling. Especially singular and plural ^^. In your json, both keys are called "dialogue". So the key in the root object as well as in the nested object.

However your root class “DialogueContainer” uses the key name "dialogues". So of course you would not see any data since that key does not exist :slight_smile: