JSONUpdate Plugin

This is actually an action widget (<$action-jsonupdate/>) to allow the manipulation of JSON data tiddlers. I know there is the jsonset filter operator, which allows you to update JSON within a variable and then you can write that JSON back to a Tiddler if you like, but that was very limited for me.

I use the jsonindexes, jsonextract and jsonget extensively, to read data, but the jsonset functionality was severly lacking for my needs in writing updates back to my JSON tiddlers.

I have created an adventure style games system within TIddlywiki and all the data for rooms, items, and everything else to do with each individual game are stored in the text field of large JSON tiddlers, that way I do not have to have separate tiddlers for each room, object, person, etc, but rather all the data and external image links are stored in the JSON files, and using a single room tiddler, item tiddler and person tiddler, I am able to stay in a single Tiddler and simply swap out the variable values on a button click to appear to navigate to another room, but instead just updating the variables of the current Tiddler with the data pulled from and written to JSON tiddlers. Basically, it is a moo, mud, muck system, but fully visual, with images, animations, ambient audio sounds and dialog, and I would not have been able to create the game system in its current state without a proper way to easily write to my JSON tiddlers directly, on the fly.

So, I created this plugin to write to json tiddlers as a necessity to complete my project, and figured it may be useful for anyone else that needs to write to JSON tiddlers more easily.

I do not have any GitHub to store the code or anything like that, and I did not write this for official release, but as I find it so useful for my needs, I figured if anyone else wanted to use it, why not. So this was not my initial intent, so if I am posting this incorrectly, I apologize, but I am just uploading the plugin as a JSON if anyone wants to import it and use it, or not. It includes a full readme on how to use it.

$__plugins_jbardi_jsonupdate.json (41.0 KB)

4 Likes

Thx for sharing.

There is no need to apologize if you contribute something back to the project. No matter where.

We’ll find a nice place😎

I am interested in this program. Is there a url?

I did test your example code a bit. It (mostly) seems to work as intended, but there are a lot of console.log() in your code. → That’s OK, but they can not be disabled.

I thought the $debug option could be used to decide where to output the debug info. So eg:

  • $debug … show modal and print to dev console
  • $debug="modal" … show the modal … as it is now
  • $debug="console" … output to dev console – no modal
  • $debug="no" … disable debugging … this one will allow us to make it dynamic <<state/value>>

Just some thoughts

1 Like

Yeah, there is a lot of console logging, again, that was due to this not originally being meant for public use, and I was just doing some debugging during dev, and never removed them. That could be cleaned up to only have console.warn for like invalid JSON, basically just anything that actually stops the data from successfully being written to the JSON and nothing else.

As for the $debug options, that actually sounds like a great idea, much more polished and useful. Again, for my personal purposes, I only needed the modal, but as I went and dumped it on here, it should be more robust in its implementation for wider use.

I do have a point of clarification on the $display=“no” option. I am not quite clear on making it dynamic and the <<state/value>> idea. Could you clarify that for me? I feel dumb like I should know what it is you are referring to LOL

Not currently. This is a personal project, a kind nostalgic labor of love, and not finalized quite yet. It was originally designed around a whole lot of tiddlers, and it was getting out of hand. So the redesigning of the entire system to work with JSON files, and the requirement to have a custom widget to deal with that has obviously caused a lack of forward movement, and more lateral movement on rewriting what was already in place. Eventually it will be at a place that it can be stably used, but for the time being, it is a side project when I am not working. Like the plugin, it was not initially meant for public use, but rather just for me, but, also like the plugin, it will probably be made available. Focusing on completion, then I’ll address what to do with it at that point.