I have a simple JSOn file with a single object:
{
"id": 1,
"file": "bars.png"
}
It returns a compiler error on the Load() call:
main.agc:30: error: Type function "load" not recognised, built in function is .fromjson(string)
If I change the JSON to array format by enclosing the original content in square brackets the call to Load() works fine.
It's rather annoying when I know a have a single object worth of data to represent with JSON and it won't load it. This example test is small so I could call fromJSON(). The real code I want to work with is a larger file that needs to be read in.
This means I have to include the "[" and "]" and re-write the code to act like its has to work with an Array of the type, when I I have is a single item. I see this as a work-around, rather than correctly allowing the load() of a JSON object from a file. It's as though you're forcing fromJSON() to be used on any single object, even though it wouldn't make sense define it in with a String. I would think most use cases would require the read from a file, regardless if its an object or an array of objects.