I have a JSON file which is a valid dump of tiddlers. When I want to import it as text into a single HTML file wiki, I have to:
create a new tiddler
set its content type to text
open the JSON file in a text editor, select everything, copy, then paste it into the text field of the new tiddler, then save the tiddler
If I try to import it via TiddlyWiki’s Import button, it makes the assumption for me and only suggests importing the JSON content as separate tiddlers. There’s nothing like an “Import as plain text” checkbox in the Import tiddler dialog.
Is there an easier way than the described above to import a JSON file as a piece of text?
I like this method because it seems like an easy way to intercept the import process and perform my own custom import. I could be wrong but it seems to miss a step.
The new JSON tiddler created is using $:/Import format like this
which is different from the original tiddlers JSON format [ { "title": "..<title>...", "text": "..<text>...", …} ... ]. So IF the original tiddlers JSON format is required, another step is needed to extract from “tiddlers” ?
I tried an alternate approach using dropzone, which is how I do custom import :
This seems to work as the content of the JSON tiddlers are indeed imported into the text field of the new tiddler, but the type is “application/json” ?
There is another way but i dont have access to my desktop to get my notes.
From memory set up a custom $browse widget and browse for .json files but force the plan text deseriliser or similar. It will not attempt to import it as json tiddlers.
Alternativly in import rename the $:/import tiddler and edit the fields to remove the plugin type. Although this can be set to plugin too.
What remains in the content of the import, the json
Alternativly in import rename the $:/import tiddler and edit the fields to remove the plugin type. Although this can be set to plugin too.
What remains in the content of the import, the json
That’s what Eric’s solution does, which he deftly packed into a SAVE button. I suppose old-timers here like yourself remembered it as a nifty trick to save imported content in json format
From what I tried, it’s in a specific json format used internally by $:/Import, which TW may have some useful routines for this format. In this case, It’s not exactly the same as the original json content, but may not matter for OP’s usage.
From memory set up a custom $browse widget and browse for .json files but force the plan text deseriliser or similar. It will not attempt to import it as json tiddlers.
Have not tested this. The mechanism seemed similar to the drop zone I tried, and may face similar issue. What I think happened is the drop zone correctly deduces that the content is “application/json” and set the tiddler type accordingly, but switch to the “text/plain” deserialiser as instructed, which processes the content correctly, just doesn’t change the tiddler type. The tiddler type can be changed post import if needed, so not a big problem.