JSONItem lookup array TypeMismatchException

  1. 6 months ago

    Michael D

    Nov 28 Pre-Release Testers, Xojo Pro

    I have a JSON item:


    And a Xojo Class:

    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?)

  2. Greg O

    Nov 28 Xojo Inc

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

  3. Michael D

    Nov 29 Pre-Release Testers, Xojo Pro

    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.

  4. Kem T

    Nov 29 Pre-Release Testers, Xojo Pro, XDC Speakers New York

    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.


or Sign Up to reply!