[tw5] Import tiddlers w/ json including custom fields

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”,
“kbalink”: “https://www.someplace.net/000020508”,
“kbarating”: 5,
“kbasev”: 0,
“kbasource”: “LKBA”,
“kbastale”: 0,
“kbatweak”: “”,
“kbatype”: “Info”
}

]

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.

JKM, This is not much of an answer, except two comments:
(1) I regularly import JSON strings with fields, needing no further configuration. (The import tiddler won’t show the additional fields, but they’ll be part of the tiddler after import, as you can see once you open in edit mode.)
(2) 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.

I don’t have time for much more testing, except to confirm that I can import your json data (using copy-paste), and yet I also see a couple unexpected character errors, and I’m not sure why.

1 Like

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

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: TW5 JsonMangler — a json plugin for TW5, v2.2.5

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

I can totally recommend Joshua’s JSON mangler in cases likele this and csv.

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.

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.