Incorrect index for array keys in C JSON decoder

, ,

When decoding a JSON array, the key path provided to shouldDecodeTableValueForKey for its elements has an index portion with digits in reverse order.

For example, when decoding this JSON:

{
  “myArray”: [
    // items
    240,
    // more items
  ]
}

Assuming that ‘240’ is the 16th element in the array, shouldDecodeTableValueForKey will be called with the key “myArray[51]”. I’d expect the key for this element to be “myArray[15]”.

I’m using SDK v2.6.2, building on macOS.

Although I’m building my app in Swift, this shouldn’t be relevant since this bridging doesn’t touch the JSON portion of the C API.

As a real life example, Trophy Case prints the path provided to it when encountering a key it doesn’t support in this function: trophy-case/Sources/TrophyCase/JSONDecoder.swift at 85d631b356d081b20a8710884604a69429a35519 · gurtt/trophy-case · GitHub