I have such a json
{
"i386": "iPhone Simulator",
"x86_64": "iPhone Simulator",
"arm64": "iPhone Simulator",
"iPhone1,1": "iPhone",
"iPhone1,2": "iPhone 3G",
"iPhone2,1": "iPhone 3GS",
"iPhone3,1": "iPhone 4",
"iPhone3,2": "iPhone 4 GSM Rev A",
"iPhone3,3": "iPhone 4 CDMA",
"iPhone4,1": "iPhone 4S",
"iPhone5,1": "iPhone 5 (GSM)",
"iPhone5,2": "iPhone 5 (GSM+CDMA)",
"iPhone5,3": "iPhone 5C (GSM)",
"iPhone5,4": "iPhone 5C (Global)",
"iPhone6,1": "iPhone 5S (GSM)",
....
}
which is just a json object of keys and values (device code and device model name). I would like to parse that with the use of Flux.
code which doesn’t work. I looked through docs and thee is no information how I can do it. If it possible at all. I want to convert that json to map or something to have a possibility to look for device model name by device code. It will be a kind of mapper
jsonRawString = "{\"i386\":\"iPhoneSimulator\",\"x86_64\":\"iPhoneSimulator\", ..."}"
jsonMap = json.parse(data: bytes(v: jsonRawString))
jsonMap
Hello @arturCwiklinsky,
Yes you have to use the json.parse function inside of a map function like shown here:
Hmm, maybe I am missing something, I am not sure how to use the map() function with that.
In the example data source is “data” which is probably a table. i don’t have a table in my example and I have only raw json string at the beggining.
To provide further clarification, I would like to create a similar file as this one below, but in JSON format and use it in my Flux queries to map specific data from this json.
github file example
I tried something like that
jsonRawString = "{\"i386\":\"iPhoneSimulator\",\"x86_64\":\"iPhoneSimulator\",\"arm64\":\"iPhoneSimulator\",\"iPhone1,1\":\"iPhone\",\"iPhone1,2\":\"iPhone3G\",\"iPhone2,1\":\"iPhone3GS\",\"iPhone3,1\":\"iPhone4\",\"iPhone3,2\":\"....}"
jsonMap = json.parse(data: bytes(v: jsonRawString))
jsonMap
|> map(
fn: (r) => {
return {
a: r._key,
b: r._value
}
},
)
but I got:
error calling function "map" @14:8-21:10: argument is not a table object: got *values.object
Could you provide more specific solution example? Any detailed leads?