I went to JSONLint which claims my JSON is valid.
Sometime back one of you wondered whether there was a “BOM” in my file, I don’t know, so here are the hexes:
I have Debug.Logged the value directly one line before attempt of deserialization (the location where the error is thrown). Console shows indeed a string and that string is my JSON string.
Weirdly enough I have a general function that handles this (it skips loops, read files and then deserializes it), this is 3th line that throws an error. I used this function twice before and no errors, but it somehow is stuck on this line.
So, what should I do?
Yes, the path is correct, otherwise it wouldn’t read the JSON into console log.
Nothing is changed between them, its a closed function that simply performs some internal processing.
Assuming that you’re using JSONUtility – JSONUtility doesn’t support deserializing raw arrays (eg. [1,2,3]), even though that is technically a valid JSON object. In order to deserialize lists or arrays, you need to place them inside of another object and serialize that, eg.
[Serializable]
class ListWrapper {
public List<int> list;
}
Which will give you JSON along the lines of { "list": [1,2,3] }.
Ah, I see. Instead of defining it as single item, I defined the T to be a List. Now it works. Thanks.
I doubt more than 10% of Scripting forum’s threads are actually about Unity-specific issues. I believe majority, including myself, use this forum as means to get help from good-willed people in any C# questions that are involved in creation of a videogame in Unity. Major of our troubles don’t come from misuse of Unity, but lack of understanding of C#.