JSON

According to this: Unity - Manual: JSON Serialization

  1. Do I have to place the [Serializable] thingy above the class name? If yes, why?
  2. Say I have an object, character, and I added one character, then as the player progresses more characters are added into the game, how can I add new ones into the Json file without overwriting the current characters?

Yes.

Because this attribute combined with the ‘SerializeFieldAttribute’ and ‘NonSerializedAttribute’ is how the serializer determines what should or shouldn’t be serialized.

Don’t serialize the character to the json file, serialize a collection of characters (an array or list).

Usually when serializing, you define some base object to be serialized… I usually call this the ‘SaveStateToken’ or something.

\
[System.Serializable]
public struct SaveStateToken
{

    public Character[] Characters;
    public Item[] Items;
    public int Level;
    public int Score;

}

Thank you.
And in case I want to do that the way I asked, how would I be able to do that?