I am trying to use KWGT in order to display list retrieved from JSON and I am facing a couple of problems. Such a JSON query ".[*].name" returns this result:
[
"element 1",
"element 2",
"element 3"
]
So, I am creating a SERIES part in KWGT and feed it with custom data using JSON query like this:
$wg(gv(web_link), json, .[1].name)$
This displays multiple times "element 1" in one line - first question here, how to separate elements with new line, so that it displays in multiple lines? Second question is how to use "index" constant within data query? This doesnt work:
$wg(gv(web_link), json, .[index].name)$
Maybe I should approach this problem in the other way? I may have several elements in the JSON result and the number of elements is dynamic, so I would like to scroll through all of them.
Hi! So the "list" global expects items to be split by comma, so in a format like "1,2,3,4" so its probably not the best approach here unless you want to then write a formula that will take the json and transform it into a list separated by comma.
Your second approach looks like the best one, you should try something like this:
$wg(gv(web_link), "json, .[" + index +"].name")$
In order to let the parser know that index should be appended (i didnt test this but it should work)
Thank you for the response - I managed to figure out the expression and in fact it works the way you show it - just the quotation starts after JSON, not before.
But now I have a problem with visualising it. I didn't manage to find any doc or tutorial showing how to display these elements in a list on a widget. I only manage to display them in one line or in a circle. How to display a list of things in a widget so that I can scroll it down (nop matter how many elements I have on the list)?
Basically I would like to see something like this on my widget: