Standard way to access a JSON tiddler from javascript

346 Views Asked by At

In a Tiddlywiki macro, what is the standard way to load JSON data from a JSON tiddler?

Currently, I've done this:

var my_dict = JSON.parse(this.wiki.getTiddlerText("my_json"))

Loving Tiddlywiki. Thank you!

1

There are 1 best solutions below

0
On BEST ANSWER

Unless a better answer comes along:

Yes, this is the way.

But note that in some cases you'll have to use the $tw object (instead of 'this'), for example in a custom parser (such as tiddler of type 'application/javascript' and module-type: 'wikirule'):

var my_dict = JSON.parse($tw.wiki.getTiddlerText("my_json_tiddler"))