[TW5][Offtopic] Why not JSON for storage?

240 views
Skip to first unread message

Tristan Kohl

unread,
Apr 6, 2016, 6:39:35 AM4/6/16
to TiddlyWiki
Hey guys,

it is me again :)

I got a little deeper look into TiddlyWiki and came to wonder why the storage of Tiddlers is implemented the way it is. As I understand it every Tiddler is a single <div> which are all stored in the "Tiddler Area". But since every Tiddler is a object with its own properties ("created", "author", etc.), wouldn't it be a logic decision to keep them as JavaScript objects and store everything as a big JSON string in the storage area so we do not need to parse it back again?

My only clue is that there are some performance thoughts which I (with my limited JavaScript skills) do not get. Any hint or link would be very much appreciated.


Thanks guys
Tristan

Jeremy Ruston

unread,
Apr 6, 2016, 9:49:27 AM4/6/16
to tiddl...@googlegroups.com
Hi Tristan

I got a little deeper look into TiddlyWiki and came to wonder why the storage of Tiddlers is implemented the way it is. As I understand it every Tiddler is a single <div> which are all stored in the "Tiddler Area". But since every Tiddler is a object with its own properties ("created", "author", etc.), wouldn't it be a logic decision to keep them as JavaScript objects and store everything as a big JSON string in the storage area so we do not need to parse it back again?

The serialisation format of tiddlers with the standalone HTML file is indeed as a bunch of DIVs with custom attributes. The origin of the format was TiddlyWiki Classic back in 2004 (before JSON was discovered). Technically, it would be quite easy to change the format to something else, but in general we don’t see sufficient payback to make it worth the effort, and the inevitable backwards compatibility problems it would cause.

Having said that, using HTML as the basis for the serialisation format does provide some interoperability with HTML/XML tooling, which is also sometimes useful.

Best wishes

Jeremy


My only clue is that there are some performance thoughts which I (with my limited JavaScript skills) do not get. Any hint or link would be very much appreciated.


Thanks guys
Tristan

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/03eeba93-0901-489e-a3cc-803559418c91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tristan Kohl

unread,
Apr 7, 2016, 6:26:53 AM4/7/16
to TiddlyWiki
Hi Jeremy,

thank you for your explanation, this helped me a lot. I also figured it could correlate with TWC but thought there might be some performance reasons for choosing the HTML method over JSON.
I will keep digging into TiddlyWiki and look forward to learn more about JavaScript so one day I can do something with my knowlege :)

Cheers
Tristan

Alex Hough

unread,
Apr 7, 2016, 7:21:47 AM4/7/16
to TiddlyWiki
Tristan,

You can export tiddlers to the JSON format.

This could open up a workflow where the JSON could be used by a framework of your choice to deliver a static website

best wishes

Alex

Tristan Kohl

unread,
Apr 7, 2016, 11:24:30 AM4/7/16
to TiddlyWiki
Hi Alex,

I just asked because I was curious, there is no workflow in my head regarding JSON. I was just wondering why Jeremy chose the HTML approach over JSON as I myself use JSON for transfer (and sometimes storage) like many other people.

Anyways thanks for your hint, I will think about a usecase with JSON ;)

Cheers
Tristan

Hegart Dmishiv

unread,
Apr 7, 2016, 11:35:20 AM4/7/16
to tiddl...@googlegroups.com
Hi,

If it's any use to anyone, I'm currently storing two collections of tiddlers externally to my wiki as JSON files, and I just pull them in when I need them. The tiddlers contained within each are all tagged, so I can quickly purge them again by filtering for that tag. This has been very useful for me as I'm generating my tiddlers in a Google Sheet, and exporting them as CSV, then converting the CSV to JSON. Whenever I've created a new batch of data in my spreadsheet, I just go through the steps and, voilà! I have a whole new set of tiddlers in my TiddlyWiki.

Hope that is useful somehow,

Hegart.

Mat

unread,
Apr 7, 2016, 3:35:47 PM4/7/16
to TiddlyWiki

If it's any use to anyone, I'm currently storing two collections of tiddlers externally to my wiki as JSON files, and I just pull them in when I need them. The tiddlers contained within each are all tagged, so I can quickly purge them again by filtering for that tag. This has been very useful for me as I'm generating my tiddlers in a Google Sheet, and exporting them as CSV, then converting the CSV to JSON. Whenever I've created a new batch of data in my spreadsheet, I just go through the steps and, voilà! I have a whole new set of tiddlers in my TiddlyWiki.

Hegart - (or anyone interested) - if I didn't refer to it already, here's a probably quicker and easier method than what you're describing to go from google sheets to tiddlers:

http://twaddle.tiddlyspot.com/#Import%20data%20using%20Google%20Sheets

<:-)

Hegart Dmishiv

unread,
Apr 7, 2016, 6:42:50 PM4/7/16
to TiddlyWiki
Hi Mat,

That's right, I remember you showing me that trick before I even started with the {{DesignWrite}} course. It might well be time I went back to doing it that way. Thanks for reminding me!

Hegart.
Reply all
Reply to author
Forward
0 new messages