JSONItem lookup array TypeMismatchException

I have a JSON item:

{"index":0,"shuffle":[],"time":0}

And a Xojo Class:

cAudio
index as integer
shuffle() as integer
time as double

So why does this code raise a TypeMismatchException?

me.shuffle = jsonItem.lookup("shuffle", me.shuffle)

My guess is that a json item of “[]” is not returning an empty integer array, but some other type (perhaps nil?)

More likely there’s no type at all since null is a valid type.

Figured it out: It’s operator error: JSONItem.lookup() on an array type returns not an array, but a JSONItem which itself holds the array items. So I need to write a simple conversion method.

Have you looked at my JSONItem_MTC project? It offers a drop-in replacement for JSONItem that is faster and overcomes some shortcomings in the native class, and separately offers functions to parse JSON into the classic Dictionary/Variant array, and generate JSON from those too.

https://github.com/ktekinay/JSONItem_MTC