1

Enhanced JSON Reading to better handle arrays

Idea: Make JSONPath syntax available in tasker.

Currently JSON query syntax in tasker does not support the JSONPath standard (currently in proposed status) as described in https://www.rfc-editor.org/rfc/rfc9535.html and https://en.wikipedia.org/wiki/JSONPath

In particular arrays are awkward to deal with, especially for more complicated structures (arrays in objects in arrays... etc.)

It's possible to work around this at the expense of additional tasker actions, or by using Javascript(Let) but it would be preferable if the standard was provided for.

Some examples which don't work well are:
%my_var(N)            Nth element of unnamed array. Have to use the rather ugly [=:=root=:=] id.
%my_var(N).property               property of Nth object.
%my_var.Name(N).property     for property of the Nth element of an array named "Name"
%my_var(N)(M).property          two dimensional array
Basically, direct addressing of array elements either is not possible or is not safe.

Tasker %my_var.Name.property(N) has the issue that property1(N) and property2(N) do not necessarily belong to the same array element if properties are absent from any of the objects in the array, and do not belong necessarily to the Nth element.

Handling the data in a Javascript(Let) action can solve this , but it would be more convenient and more efficient if tasker itself had better array handling.

Is there any prospect of this being enhanced to allow JSONPath syntax to be supported, as per rfc9535 ?

For example there is a Java implementation "JsonPath" which does conform to rfc9535 described at :
https://github.com/json-path/JsonPath and https://www.baeldung.com/guide-to-jayway-jsonpath
Paths would be similar to $.Name(N).property or $['Name'][N]['property'] and so on where $ represents the root.
"JsonPath" also provides functions and filter operators some of which which could help make data processing a lot easier and faster in tasker.

If this is feasible, then it might be possible to allow the existing syntax to co-exist with JsonPath either by presence of the $ indicator or an option in "Set Variable Structure Type"