Json structure without keys

Hi.
I’m new to json.
I downloaded some information in json format, but it looks different from what I’ve seen in my searches.
The basic structures consists of two objects: an array of arrays without keys and an array of objects wiht key:value pairs.

{
“resultset”: [
[
“value0”,
“value1”,
“value2”,
“value3”,
“value4”,
“value5”,
“value6”,
“value7”,
“value8”
],
[
“value0”,
“value1”,
“value2”,
“value3”,
“value4”,
“value5”,
“value6”,
“value7”,
“value8”
],
<…>
[
“value0”,
“value1”,
“value2”,
“value3”,
“value4”,
“value5”,
“value6”,
“value7”,
“value8”
]
],
“metadata”: [
{
“colIndex”: 0,
“colType”: “String”,
“colName”: “key0”
},
{
“colIndex”: 1,
“colType”: “String”,
“colName”: “Key1”
},
{
“colIndex”: 2,
“colType”: “String”,
“colName”: “Key2”
},
{
“colIndex”: 3,
“colType”: “String”,
“colName”: “Key3”
},
{
“colIndex”: 4,
“colType”: “String”,
“colName”: “Key4”
},
{
“colIndex”: 5,
“colType”: “String”,
“colName”: “Key5”
},
{
“colIndex”: 6,
“colType”: “String”,
“colName”: “Key6”
},
{
“colIndex”: 7,
“colType”: “Numeric”,
“colName”: “Key7”
},
{
“colIndex”: 8,
“colType”: “Numeric”,
“colName”: “Key8”
}
]
}

Never seen this structure before. It’s a json object whi only two values: the first one looks like the values of a key:value pair, and the second one looks is an array of objects containg the description of each key value. I searched over the web trying to find similar structure with no success.Very weird.
How do I treat this object? How do I create a struct for those variables in Swift and how to parse that?

Thanks a lot!
wagmun

Hi @wagmun, welcome to JSON.

Unfortunately, this forum is not the right place for your question as it is dedicated to the JSON:API specification, a standard for people to exchange JSON without having to re-invent formats and field names (TL;DR).

I suggest that you have a look at Stack Overflow instead, more specifically questions about “how to parse JSON in Swift”. Once you can read your message in Swift, you’ll be able to write a algorithm to process it. Also, let people know the context, maybe there is already an algorithm for that.

1 Like