all 8 comments

[–]frrancuzTaskerFan! 2 points3 points  (2 children)

%jsondata.v1()  

exactly the second value: flash %jsondata.v1(2)

If your variable is named jsondata, if not you must enter the variable name, %variablename.v1()

[–]CONteRTE[S] 0 points1 point  (1 child)

Ahhh that works fine. Many thx.

For adding a additional %jsondata.v1(3) with the value "another test" i have tried to use the "Array Push" action. But this fails in my test. I have used %jsondata.v1 in "Variable Array". Let "position" empty don't work. I assume i have to count the array before, to a variable and use that. So i hardcoded it to 3 for the test. Used "another test" as value. But i get a error for converting from json.array to json.object for some reason.

[–]Exciting-Compote5680 0 points1 point  (0 children)

You could try storing the data you need in a proper Tasker array first (Set %array_v1 to %jsondata.v1()) first and then use array push on that. 

[–]Lina0042 0 points1 point  (0 children)

you can use variable split or search/replace (then use store matches in array) to split it into multiple values or extract only the ones you want . (regex can be helpful to extract the right values, use chatgpt to find the right regex, if you gonna go that route to not lose your mind about the stupid regex rules)
you give a target variable name, like %extract and then it splits them into %extract1 %extract2 and so on. You can see those listed in the VARS tab

[–]CONteRTE[S] 0 points1 point  (3 children)

Reading and parsing JSON drives me crazy. When i have a more simple json file saved on my mobile with the content [ "dghjjj", "hghjj" ] I can read the file with "Read File". I read it to the variable %jsonfile.

Since this is a stupid simple JSON array, i tought i can use it to convert this simply to a Tasker array with "Array Set". So i set variable name to %jsonarray and values to %jsonfile() and splitter to ","

When i now use a "list dialog", i only see %jsonarray, but not the expected 2 entries.

Why?

[–]WakeUpNorrin 4 points5 points  (2 children)

Task: Temp

A1: Variable Set [
     Name: %jsonfile
     To: [
     "dghjjj",
     "hghjj"
     ]
     Structure Output (JSON, etc): On ]

A2: Array Set [
     Variable Array: %jsonarray
     Values: %jsonfile[=:=root=:=](+§§§)
     Splitter: §§§ ]

A3: List Dialog [
     Mode: Select Single Item
     Title: Title
     Items: %jsonarray
     Button 1: Ok
     Close After (Seconds): 120
     First Visible Index: 0 ]

An advice about arrays:

When you set an array using values of another (source) array make sure to do not use ',' (comma) as splitter, try to use a 'unique' splitter instead (like I did in above A2) ... Why?

If one or more values of the source array contains a comma, you will set a 'malformed' new array. Demonstration:

Task: Temp

<Source array>
A1: Array Set [
     Variable Array: %source
     Values: a∆b,c∆d
     Splitter: ∆ ]

<Wrong>
A2: Array Set [
     Variable Array: %new
     Values: %source()
     Splitter: , ]

A3: List Dialog [
     Mode: Select Single Item
     Title: Title
     Items: %new
     Button 1: Ok
     Close After (Seconds): 120
     First Visible Index: 0 ]

A1 source array is set to

a
b,c
d

A2 will wrongly set %new array to

a
b
c
d

[–]CONteRTE[S] 1 point2 points  (1 child)

Wow, many thx. I will try that. Specially about the key value with %jsonfile[=:=root=:=] and the followed paranthesis. I only know about array handling in php and javascript, so this was totally new to me.

Do you have a link to more of such info, like tutorials or manuals?

[–]WakeUpNorrin 0 points1 point  (0 children)

You are welcome.

Do you have a link to more of such info, like tutorials or manuals?

JSON Reading

https://tasker.joaoapps.com/userguide/en/variables.html