Write a list of a class in Json using LitJson

Hi

I have a class that contains a few strings and then a variable that is a list of this class. The list gets populated during playtime. I then need to save it. In order to save it I do this.

    public void SaveLanguage()
    {
        Language newLang = new Language(words);
        languageJson = JsonMapper.ToJson(newLang);
        File.WriteAllText(Application.dataPath + "/MyLanguage.json", languageJson.ToJson());
    }
}

public class Language
{
    public List<Word> words;

    public Language(List<Word> words)
    {
        this.words = words;
    }
}

Now this works but it doesn’t really work. It does save it in a Json file but it doesn’t format correctly. So basically, how do I save a List of a class in Json? As I said before, the class basically just contains 3 strings and the class is called Word. Therefor no need to show it here.

If any other information is needed, please tell me!

Thanks in advance!

I am not very observant…
I’ve written .ToJson() on line 5 instead of .ToString(). To fix my problem I simply replaced ToJson with ToString and everything worked.