• Moritoki Mochizuki
    Moritoki Mochizuki
    2022-10-15

    Sollte nach Spezifikation eigentlich "uniq" sein der Bezeichner.
    Ansonsten würde alles, was ich jemals als JSON-Reader implementiert habe, immer den letzten key und dessen value nehmen ;)

    0
  • John Wehrle
    John Wehrle
    2022-10-15

    In terms of the json itself, the list could be enclosed in another json with the type such as { type: type, list: [], } but I don't know if that's what they're looking for.

    0
  • Moritoki Mochizuki
    Moritoki Mochizuki
    2022-10-15

    I do not know, what ist a "list" in his example ;) Just an array, so names are nothing to take care about. But associative arrays - one name has to be unique. It should (may be) throw an error if the "key" is used again. But most simple readers I did see and program use last key/value pair. I think this depends on validating input.

    0
  • John Wehrle
    John Wehrle
    2022-10-15

    In json format the key for the array can be whatever they want and the elements of the json array can be any json object they want. If they have control over the json formatting then the above should work but if not then the solution will have to be in python.

    0
  • Andrew Pam
    Andrew Pam
    2022-10-15

    It might help to use JSON Schema.

    0
  • Sunyata ☸ 👨🏻‍💻 ☮
    Sunyata ☸ 👨🏻‍💻 ☮
    2022-10-17

    Thank you everyone for your comments! Basically what i'm trying to do is to avoid storing the type for each element in the JSON array, when i already know the type. (Python doesn't know the type though, since lists in Python can have elements of different types)

    In the question i used the wrong word when talking about the JSON array (it's called array and not list)

    PS: There is a type of data structure in Python called array, but that is not suppored (Also Python arrays cannot have string elements)

    0