Unable to import this .json file

123 views
Skip to first unread message

Suzanne McHale

unread,
Feb 4, 2019, 10:03:01 PM2/4/19
to TiddlyWiki
Tried to import this into a fresh empty tiddler (most recent version), but nothing shows up after the import button is clicked. Is the file of the correct type?
foreigner-characters.json

TonyM

unread,
Feb 5, 2019, 6:09:25 AM2/5/19
to TiddlyWiki
Suzanne,

A quick view of this file indicates it does not appear to contain tiddlers within it but another json format. As a result I believe the import process does not know how to handle it.

I suggest create a tiddler and paste the content of the json file into it and set the tiddler type.

There are tools for querying json that you can try like treating it as a data tiddler and plugins available.

More information on its source and what you intend to do with it will inform us so we can help more.

Tony

Eric Shulman

unread,
Feb 5, 2019, 9:18:19 AM2/5/19
to TiddlyWiki
On Monday, February 4, 2019 at 7:03:01 PM UTC-8, Suzanne McHale wrote:
Tried to import this into a fresh empty tiddler (most recent version), but nothing shows up after the import button is clicked. Is the file of the correct type?

TiddlyWiki *can* import JSON files, but only if the 'records' in the file contain certain field names.  Most important, each JSON record must have a uniquely-valued "title" field.  This is used to create the corresponding tiddler.  The remaining field names in the JSON record can be anything you like.  However, keep in mind that certain field names have special meanings in the TWCore system.  Specifically, "title", "text", "tags", "created", "creator", "modified" and "modifier" should be considered not be used as general-purpose field names.

Also note that the TWCore's JSON processing does *not* handle complex nested JSON structures... just plain name/value pairs within a simple list of top level objects.

Here's an example of a simple JSON file that can be imported to create tiddlers:

[
   
{
       
"title": "TiddlerTitleGoesHere",
       
"text": "Tiddler content here",
       
"tags": "Tiddler tags here",
       
"foo": "This is a field named foo",
       
"bar": "This is a field named bar"
   
},
   
{
       
"title": "AnotherTitle",
       
"text": "Tiddler content here",
       
"tags": "Tiddler tags here",
       
"foo": "This is a field named foo",
       
"bar": "This is a field named bar"
   
}
]


enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

Suzanne McHale

unread,
Feb 5, 2019, 9:49:27 AM2/5/19
to TiddlyWiki
Thanks for responding! I saved the file in .json format from this database: http://trackmysoftware.com/cj/characters_view.php, so it is not a TW-created one initially.

Suzanne McHale

unread,
Feb 5, 2019, 9:54:38 AM2/5/19
to TiddlyWiki
Hi, I saved the file from here: http://trackmysoftware.com/cj/characters_view.php, so looks like I’ll have to do a bit of search-and-replace to make it compatible :/.

TonyM

unread,
Feb 5, 2019, 6:00:05 PM2/5/19
to TiddlyWiki
Suzanne,

Do you wish to convert them to tiddlers?

Do you have alternative export options like csv or exel?

All of these have tools available for tiddlywiki.

Regards
Tony

Suzanne McHale

unread,
Feb 5, 2019, 9:03:32 PM2/5/19
to TiddlyWiki
Hi Tony, I was hoping TW would convert them all to separate tiddlers for each entry.

TonyM

unread,
Feb 5, 2019, 11:16:47 PM2/5/19
to TiddlyWiki
Suzanne,

Only if they are in fact tiddlers. Such as when you export tiddlers to a json file.

  • Do you have alternative export options like csv or exel?

All of these have tools available for tiddlywiki.


You need to provide more details about your data, and what you plan to do so we can help you more.



If I look at your data each case looks like this


  {
   
"cno": 137,
   
"cname": "Adams town",
   
"group": "Location",
   
"book1": "01. Foreigner",
   
"book2": "",
   
"change": "",
   
"job": "",
   
"household": "",
   
"notes": "Human city, on Mospheira."
 
},

You need to work out what will be the tiddler name (needs to be unique or made so), fields or tags at a minimum.,


With this json inside a tiddler, as I recommended, I expect you can treat it like a "data Tiddler" and use the "##" form of  tiddlername##dataname eg tiddlername##cname


I have not yet done a lot of this to be sure, but that will get you on track.


Regards

Tony

Mark S.

unread,
Feb 6, 2019, 12:36:04 AM2/6/19
to TiddlyWiki
Change "cname" to "title" globally, and "notes" to "text" and you'll have something you can immediately dragon-drop.

-- Mark

Mohammad

unread,
Feb 6, 2019, 1:13:47 AM2/6/19
to TiddlyWiki
Added to TW-Scripts.

Suzanne McHale

unread,
Feb 6, 2019, 1:56:13 AM2/6/19
to TiddlyWiki
That worked! :-) All imported as separate tiddlers (I also changed "group" to "tags"). I'll still have to do some tweaking, but that is the bulk of the work done.

TonyM

unread,
Feb 6, 2019, 3:04:16 AM2/6/19
to TiddlyWiki
Suzanne,

I am working to get some better answers and develop a deeper understanding myself. 


I notice the field that proceeds title, cno is not imported, if you could ensure this comes after the field you make into title it should also import (If you can choose at the time you create the json).

Now that the tiddlers are there you can search or test for values in fields and list those with the same values.

Anyway enjoy mastery of your data now its in TiddlyWiki.

Tony

@TiddlyTweeter

unread,
Feb 6, 2019, 7:09:51 AM2/6/19
to tiddl...@googlegroups.com
TonyM and all

The import of JSON files without a "title" field can sometimes be problematic.

Suzanne found the best solution to her situation by renaming fields. Relatively easy once you know what to do. Good solution in her use case.

But there is another common case where you can't really identify a field suitable for "title" in a JSON ... a case would be hundreds of short unrelated texts like Tweets where there are no suitable fields other than the "text".

To address this issue Riz developed a nifty plugin that will assign titles to JSON records without titles and auto-enumerates tiddlers as it creates them.


Best wishes
Josian
Reply all
Reply to author
Forward
0 new messages