action-delefield et json

68 views
Skip to first unread message

Jean-Pierre Rivière

unread,
May 3, 2021, 4:45:29 PM5/3/21
to TiddlyWiki
I have  tiddler "data" of json data like 

{
  "foo": { ... },
  "bar": { ... }
}

I want to get rid of "foo".

so I have setup a $button where the action is

<$action-deletefield $tiddler="data" $field="foo"/>

the action does nothing (if I set an action-deletefield instead, it works so the problem is just the deletefield widget).

any idea?

Jean-Pierre Rivière

unread,
May 3, 2021, 5:09:25 PM5/3/21
to TiddlyWiki
of course, I have installed json mangler and its necessary plugins as well. they work.

Jean-Pierre Rivière

unread,
May 4, 2021, 8:02:06 AM5/4/21
to TiddlyWiki
Resolved my problem.

to delete a fied or an index, you can (and in json that's an index, so it's "you must") use $action/setfield without specifying any $value.

thus to get rid of "foo" in my previous example all I have to do is:

<$action-setfield $tiddler="data" $index="foo"/>

this possibility should be recalled in the doc of $action-deletefield.

and why is there not any $acion-deleteindex?

Le lundi 3 mai 2021 à 22:45:29 UTC+2, Jean-Pierre Rivière a écrit :

PMario

unread,
May 4, 2021, 8:49:35 AM5/4/21
to TiddlyWiki
On Tuesday, May 4, 2021 at 2:02:06 PM UTC+2 jn.pierr...@gmail.com wrote:
thus to get rid of "foo" in my previous example all I have to do is:
<$action-setfield $tiddler="data" $index="foo"/>

Right, that's a bit strange.
 
this possibility should be recalled in the doc of $action-deletefield.

Or $action-deletefield should get a $index parameter, because I think that's the function where users would expect it.
Right?

-mario

PMario

unread,
May 4, 2021, 8:52:40 AM5/4/21
to TiddlyWiki
On Tuesday, May 4, 2021 at 2:02:06 PM UTC+2 jn.pierr...@gmail.com wrote:
...
and why is there not any $acion-deleteindex?

IMO because, if users know how to do it, they use the existing functionality.

-m

Jean-Pierre Rivière

unread,
May 4, 2021, 1:24:15 PM5/4/21
to TiddlyWiki
well, the current way of deljeting an index is not very satisfying from the readability point of view. so yes, an $action-deleteindex is as justified as $action-deletefield. and if not, then $action-deletefield should get an $index parameter.

BTW, I think it would be good to allow for a "getfield" homonym for "get" filter operator, for a naming consistency.

PMario

unread,
May 5, 2021, 1:03:35 PM5/5/21
to TiddlyWiki
On Tuesday, May 4, 2021 at 7:24:15 PM UTC+2 jn.pierr...@gmail.com wrote:
well, the current way of deljeting an index is not very satisfying from the readability point of view. so yes, an $action-deleteindex is as justified as $action-deletefield. and if not, then $action-deletefield should get an $index parameter.

BTW, I think it would be good to allow for a "getfield" homonym for "get" filter operator, for a naming consistency.

Yea, consistency is good. But having 2 things, that do the exact same thing, is a bad thing ;)

Users don't know, which one to use. .. And we do have some "deprecated" elements in TW but I'm not sure, if they will ever be removed. ...

So we need to be careful, what we add. We have to live with it for a loooooong time.

-m

PMario

unread,
May 5, 2021, 1:04:25 PM5/5/21
to TiddlyWiki
On Tuesday, May 4, 2021 at 7:24:15 PM UTC+2 jn.pierr...@gmail.com wrote:
well, the current way of deljeting an index is not very satisfying from the readability point of view. so yes, an $action-deleteindex is as justified as $action-deletefield. and if not, then $action-deletefield should get an $index parameter.

You should create an issue at github for this one. I'll +1 it ;)
-m
Reply all
Reply to author
Forward
0 new messages