On Wednesday, June 24, 2020 at 7:14:13 AM UTC-7, Robert Jopling wrote: > > When I try a test JSON structured as suggested I get the following error > message > JSON error: SyntaxError: JSON.parse: unexpected character at line 8 > column 1 of the JSON data > That character is the closing square bracket. >
JSON parsing can be somewhat finicky if the input is not 100% well-formed. The problem here is that you have a trailing comma on the last entry! I set up a tiddler in the format that I want and exported it to see the > structure and then created the following file JSON2 with the additional > fields after the 'modified' field. > On import nothing happens! > Any explanation? To help me see what might be happening, I took the first entry in your JSON2 file, and split it on the commas to show one field per line... here's the result: [{ "created": "2.02E+16", "text": "", "Tags": "", "Title": "Ailsa Craig Lighthouse", "": "", "modified": "2.02E+16", "Name": "Ailsa Craig Lighthouse", "Area": "Ayrshire", "Lat": "55.2521", "Long": "5.108716667", "Island_mainland": "Ailsa Craig", "Year_built": "1886", "Built_by": "Thomas & David A Stevenson", "Operated_by": "NLB", "Tower_height": "11m", "Focal_height": "18m", "Range": "17 nm" }, I think I see three separate problems with the above JSON input: 1) All fieldnames in TW must be *lowercase* only. I did a quick test, and TW ignores any JSON fieldnames that are not lowercase. Thus, because "Title" is capitalized, none of your entries actually have a valid title field, so they are not imported. 2) In between the "Title" and "modified" fields, there is an entry with *no name* (and no value). This doesn't prevent the entries from being imported (once the capitalization problem is fixed), but in the resulting imported tiddlers, there is a *field with no name*, which appears when you edit any of those tiddlers, but which then cannot be deleted using the trashcan icon next to the field in the TW edit view. 3) The "created" and "modified" field values seem to have been converted into scientific notation (i.e., "2.02E+16"). For these to be used as TW field values, they need to be the full 17-digit numbers (e.g., "20200624000000000"). Note that if you can't get your application to output the full 17-digit values without converting them to scientific notation, you *can* just omit those fields entirely. However, when imported, none of your tiddlers will appear in the sidebar "Recent" list, though they will still appear in the list shown under "More>All". When you then edit/save each of those tiddlers, a proper "modified" field will be automatically added, but the "created" field will still be missing. So... give it another try, where your JSON file has: 1) no capitalized fieldnames 2) no blank fieldnames 3) 17-digit date/time stamps for "created" and "modified" Again, let me know how it goes... -e -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/495dcf6e-947c-4909-95d3-4cdce9ce85b2o%40googlegroups.com.