json access when not in action mode?

55 views
Skip to first unread message

Jean-Pierre Rivière

unread,
Apr 28, 2021, 11:02:14 AM4/28/21
to TiddlyWiki
How can I access json data in a smart way when my code is not in the context of a button-started action (which I call action mode)?

say this simple text of my "data" tiddler:
-----------------
[
  { "captain": "Hook", "age": "42" },
  { "captain": "Planet", "age": "37" }
]

the indexes filter returns 0 and 1.

with get[0] I would get { "captain": "Hook", "age": "42" }

I can't get[0/name] to get "Hook".

IS there a plugin or any other mean to get:
- the names of the fileds within any json objects?
- getting any values from json with a syntax like that I give, or even a more ambitious xpath query?

I have installed json mangler. but I have no docs about it, not even knowing what it really does besides providing a bar for json tiddlers?

regards.

-- 
Jean-Pierre

Mark S.

unread,
Apr 28, 2021, 11:42:01 AM4/28/21
to TiddlyWiki
<$list filter="[[mydata]getindex[0/age]]"/>

(assuming JSON mangler)

Joshua Fontany

unread,
Apr 28, 2021, 6:44:00 PM4/28/21
to TiddlyWiki
Yes. This is exactly why I wrote JsonMangler (the "Manger" part came from one of the core features that has been downplayed, the ability to compress multi-level Json into a 1 level deep object with "path":"value" pairs. The path syntax is "/" to be consistent with the "system tiddler" naming convention in TW.

The current demo wiki/docs are located here: https://chronicles.wiki/TW5-JsonMangler/

You can use "index-path syntax" in any existing filter or widget. (Note: Stable on 5.1.23, I have not tested against the recent pre-release).

Mahalo (thanks) for trying my plugin!

Best,
Joshua Fontany

Jean-Pierre Rivière

unread,
Apr 29, 2021, 6:04:27 AM4/29/21
to TiddlyWiki

I had already looked at it... It doesn't help me so much as I wished.

Just take at example. one of the first interesting see we can see on the default tiddler is tsort. Not much told' no link provided. So I type "tsort" in the search query, and can have to 3 tiddlers incorporating tsort in their names. The examples provided don't tell much, and not any indication of the purpose.

I would gladly like to help make for a better documentation if you agree... This is time consuming, but this would reduce my own time trying to figure out things (or giving up altogether and being back to nowhere).

cheers.

-- 
Jean-Pierre
Reply all
Reply to author
Forward
0 new messages