Jsonget: return a string with spaces as text?

I am playing with the jsonget operator.
Everything works as expected, but when I use it on a string with spaces, it returns a link instead of plain text/string:

DatJSON:

{
  "1": "String contains spaces",
  "2": "StringWithoutSpaces"
}

Tiddler:

<$set name="JSONtest" tiddler="DatJSON">
<$set name="JSONstringSPC" filter="[<JSONtest>jsonget[1]]">
<$set name="JSONstring" filter="[<JSONtest>jsonget[2]]">
<<JSONstringSPC>><br>
<$text text=<<JSONstringSPC>>/>

<<JSONstring>><br>
<$text text=<<JSONstring>>/>

Output:


String contains spaces (linked to non-existent Tiddler “String contains spaces”)
[[String contains spaces]]

StringWithoutSpaces
StringWithoutSpaces


The TextWidget returns a string as supposed, but shows the surrounding brackets instead.
I suspect that this is owed to TiddlyWiki behaviour (surrounding a string with spaces with brackets). Is there an easy way to show only the string with no surrounding brackets?
Retrieving the substring would be a choice, but I hope that there is another one, too.

Is there a way to evaluate the filter expression “[jsonget[1]]” in the advanced-search (filter), too? I don’t know how to assign the JSON structure in the filter.

Any ideas are welcome.
Cheers!

This is due to the behaviour of the $set widget that is returning a title list, in which words with spaces are wrapped in brackets. Read the section of the documentation titled “Filtered Item Variable Assignment Single Element”

Alternatively you can use the $let widget with a filtered attribute value:

<$let JSONstringSPC={{{ [<JSONtest>jsonget[1]] }}}>

See:
https://tiddlywiki.com/#LetWidget:LetWidget%20[[Filtered%20Attribute%20Values]]

2 Likes

Thank you, @saqimtiaz - this does it very nicely. Also thanks for linking documentation. It is all documented, but one have to find, read AND understand it. The later is still hard for me.

1 Like