#Json issues
1 messages · Page 1 of 1 (latest)
If I've this enum:
public enum Leary
{
Aanvallen, // Attack
Leiden, // Lead
Verdedigen, // Help
Volgen, // Follow
}
And this structure for it:
using System;
namespace DialogueSystem
{
[Serializable]
public class Wrapper
{
public Dialogue[] dialogues;
}
[Serializable]
public class Dialogue
{
public int id;
public int[] refIds;
public Leary leary;
public bool correct;
public string speaker;
public string text;
}
}
And a sample out of the json loaded would be
{
"dialogues": [
{
"id": 17,
"correct": null,
"speaker": "Peter",
"leary": "Volgen",
"text": "Laten we het proberen.",
"refIds": null
}
]
}
It should just be loaded correctly, no? Right now it just defaults everything to the first enum element, Aanvallen, so something with it being read with the JsonUtility is going wrong and I don't know what. Everything else does gets loaded correctly and has been working fine for a long time now
Enums in Unity are serialized as integers
I would expect a number 0-3 for the enum in the json
o, so not as string?
no
So like every leary entry in my json I've to change to the matching integer instead?
Ah yup that was it, thanks so much
I looked up things but got confused somewhere and did it wrong ehheh