HowTo import JSON files of tiddlers as only JSON in bulk

Folks,

I have a lot of macros saved as multi-tiddler JSON files. I want to drag and drop them or import more than one at a time, however they all trigger the Import mechanism and are expanded into separate tiddlers.

I wanted to import them in bulk from files to JSON tiddlers.

This looses the JSON file name and they are expanded into tiddlers to import. Not longer as there were on disk, and other JSON files are just not imported.

Solution Found
using browse widget: Create a “files Button” as follows;

<$browse multiple deserializer="text/plain">

  • Selecting JSON files with or without tiddlers contained in them will be imported as text/plain and not expanded, however their type field will be set to application/json
  • These tiddlers can be dragged between wikis without being expanded.
  • If you use this method to import .tid files they are imported such that the new tiddler has the title.tid and the text contains the tiddler as it appeard on disk, with all fields and text content. Perhaps good for pasting on a forum.

Example text of imported .tid file using above solution

caption: {{$:/language/SideBar/Contents/Caption}}
created: 20140809114010378
list: HelloThere Learning [[Working with TiddlyWiki]] [[Customise TiddlyWiki]] Features Languages Editions Plugins Platforms Reference Community About
list-after: $:/core/ui/SideBar/Open
modified: 20150414070242411
tags: $:/tags/SideBar
title: TableOfContents
type: text/vnd.tiddlywiki

<div class="tc-table-of-contents">

<<toc-selective-expandable 'TableOfContents'>>

</div>

I am still looking how to

  • create a drop zone to do this
  • a method to extract the tiddlers from a JSON file containing tiddlers when desired.

If you change the filename extension from “.json” to something else (e.g., “.jsonX”), then the TWCore won’t recognize them as JSON and will import them as simple text files… one tiddler per file.

-e

1 Like

@EricShulman I guessed that, but I have dozens of files, in multiple folders and there functionality normally is derived from the fact they are JSON files. I wonder if there is a way to temporarily defeat the treatment of JSON files at import, so they are treated as standard files. Or as discussed, I feel I should make a custom drop zone.

For some time I have felt creating side bar tab(s) that act as alternate drop zones that treat the dropped files differently, would be a good idea. The only thing stopping me so far is one can’t open a tab on hover (while dragging content).

This subject came up here for a different reason. Importing a tiddler with a specific name - #3 by TW_Tones

You can try to load them with the tiddlywiki.files method.

@joshuafontany thanks for the lead but is this limited to “TiddlyWikiFolders” or node implementations?

Unfortunately I do not know where to start with this reference tiddlywiki.files Files

As I read it the tiddlywiki.files is in effect a file on disk on a node implementation. This is not providing an interactive way to import JSON files containing tiddlers.

Ah. Yes that would be node specific. Hrm, could you post an example file? Was this exported from TW?

@joshuafontany the issue is if I import multiple json files at once, such as using <$browse multiple/> or drag and drop;

  • JSON files containing tiddlers are all expanded into one import of tiddlers not JSON files
  • JSON files NOT containing tiddlers, ie from any other source triggers the import tiddlers process with no tiddlers listed.

I have found a solution but will leave the working notes here.

  • Now I though I could find someway the import process would no know how to process a JSON file, such that it is imported as a file (rather than expanding it) however I have come accross a little mystery

If we look at the Import button ## $:/core/ui/Buttons/import

<div class="tc-file-input-wrapper">
<$button tooltip={{$:/language/Buttons/Import/Hint}} aria-label={{$:/language/Buttons/Import/Caption}} class=<<tv-config-toolbar-class>>>
<$list filter="[<tv-config-toolbar-icons>match[yes]]">
{{$:/core/images/import-button}}
</$list>
<$list filter="[<tv-config-toolbar-text>match[yes]]">
<span class="tc-btn-text"><$text text={{$:/language/Buttons/Import/Caption}}/></span>
</$list>
</$button>
<$browse tooltip={{$:/language/Buttons/Import/Hint}}/>
</div>

I can not actually understand the action(s) that are triggered. And thus follow the trail.

I looked at both the browse and drop zone widgets which both also trigger an import and recognised that the file is handled according to the deserializer.

So I tested a custom browse widget as follows;
<$browse multiple deserializer="text/plain">

And this imports them as JSON files without attempting to expand them into tiddlers, including JSON files not containing tiddlers.

Presumably I could also make a dropzone with the deserializer="text/plain" however that needs work for me.

The imported tiddlers are not in a ready format for conversion to tiddlers, I will post back when I have a mechanism both for reexport as files and to import the containing tiddlers.

I have returned here, when about to ask a question, and found I had answered it previously.

Any help on this however would be appreciated;

So far I have tried

  • the various JSON tiddler macros
  • Removing the type
  • Adding plugin-type = plugin
  • Adding plugin type import status pending and renaming to $:/import is not working either.

However I am having difficulty accessing the “subTiddlers” in the file.

I am also getting unknown

Internal JavaScript Error
Well, this is embarrassing. It is recommended that you restart TiddlyWiki by refreshing your browser
Uncaught TypeError: Cannot convert undefined or null to object

Here is an example JSON file containing a tiddler.
history-sidebar.json (536 Bytes)

Exported from tiddlywiki, yes.