Import tiddlers w/ json including custom fields

86 views
Skip to first unread message

John Mayes

unread,
Aug 18, 2021, 2:22:26 PM8/18/21
to TiddlyWiki
New member here.  Windows, TiddlyDesktop v0.0.14, TW 5.1.23

I'm able to import tiddlers from json with the title and text fields.  But when I try to do it with a custom field the import tiddler shows no items to import.  All my custom fields begin with kba and some additional alphanumeric characters.  The json is valid according to jsonchecker.com.  Is this permitted?  Do I need to enable a feature or preconfigure a system component?  I've done a few searches in the group but didn't see anything that applied.  All help is appreciated.

Imports:
[
  {
    "title": "000019464",
    "text": "How to change the default root password"
  },
  {
    "title": "000020508",
    "text": "Best Practices"
  }
]

Doesn't import:
[
  {
    "title": "000019464",
    "text": "How to change the default root password",
    "kbalink": " https://www.someplace.net/ 000019464",
    "kbarating": 3,
    "kbasev": 0,
    "kbasource": "LKBA",
    "kbastale": 0,
    "kbatweak": "",
    "kbatype": "How To"
  },
  {
    "title": "000020508",
    "text": "Best Practices",
    "kbarating": 5,
    "kbasev": 0,
    "kbasource": "LKBA",
    "kbastale": 0,
    "kbatweak": "",
    "kbatype": "Info"
  }
]

Soren Bjornstad

unread,
Aug 18, 2021, 3:26:05 PM8/18/21
to TiddlyWiki
Your second example imports as expected for me. Is it possible tiddlers with the titles in your JSON already exist in the wiki? I believe there is a bug in 5.1.23 where it doesn't explain that to you in the import dialog and just silently skips them.
Message has been deleted

springer

unread,
Aug 18, 2021, 3:45:50 PM8/18/21
to TiddlyWiki
JKM, 

After putting quotes around your numbers (and fixing where a So-called "smart" quote had crept in during my editing, sorry about my earlier post, now deleted), both records import fine for me.

I have found that raw numbers for field content (as in your kbarating field) will not work; only data enclosed in quote marks seems to work.

Note the field data (beyond title and text) doesn't show in the import preview tiddler. But the data should be in there, as you can confirm by entering edit mode for the tiddlers once imported.

-Springer

Joshua Fontany

unread,
Aug 18, 2021, 7:20:49 PM8/18/21
to TiddlyWiki
The "Deserializer" for "application/json" files that are Objects (with minimum "title" field), or Arrays of such objects, does include a check to see if the value is a string:
```
if(typeof incomingFields[f] === "string") { fields[f] = incomingFields[f]; }
```
This is stripping out your other data.

I have a set of JSON tools that helps around this issue: https://chronicles.wiki/TW5-JsonMangler/

The worflow would be to drag& drop the JSON file into a wiki with the plugin installed, and use the Import tools in the JSON tiddler's toolbar to import each object as its own tiddler.

You can even map json field names to tiddler field names, and there's some other options.

Best,

Joshua Fontany

TW Tones

unread,
Aug 18, 2021, 7:46:35 PM8/18/21
to TiddlyWiki
I can totally recommend Joshua's JSON mangler in cases likele this and csv.

Soren Bjornstad

unread,
Aug 18, 2021, 11:16:40 PM8/18/21
to TiddlyWiki
By the way, when I said that the example "imported correctly" for me, it indeed did not include some of the fields...for some reason I foolishly decided not to mention that when I imported it even though I noticed. I am not however seeing the message jkm was where $:/Import said there were no tiddlers to import. So I think there are two separate problems here, the existence of duplicate tiddlers and some of the fields not being strings.

John Mayes

unread,
Aug 19, 2021, 3:26:33 AM8/19/21
to TiddlyWiki
Thank you all!  So glad I found this Group.  I was able to import after quoting the numbers.

@Soren Bjornstad - I searched for duplicates on a couple of them and they did not exist before the import, so I'm not sure what to make of your observation.  Looking forward to utilizing your Grok TiddlyWiki book and have already shared it with the person who introduced me to TW - He was impressed.  Certain appears to be a labor of love (and probably some frustration).
@ Joshua Fontany - I will definitely dig into your plugin.

Reply all
Reply to author
Forward
0 new messages