-
I am considering writing a script to parse a custom json file and import some of the content into trilium. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I think it would be easier to create a script which converts your custom JSON file into the format expected by trilium (ZIPped folder hierarchy of HTML files) |
Beta Was this translation helpful? Give feedback.
-
I ended up writing a backend script to parse the json and create notes as needed. I created a child note with the json file and imported it like this: ` json.entries.forEach(function parseEvents(item, eventIndex) { |
Beta Was this translation helpful? Give feedback.
-
For future readers, 0.50 will contain a REST API (called ETAPI) which will be probably for this use case easier to use. |
Beta Was this translation helpful? Give feedback.
I ended up writing a backend script to parse the json and create notes as needed. I created a child note with the json file and imported it like this:
`
const dataNote = api.currentNote.children[0];
const json = dataNote.getJsonContent();
json.entries.forEach(function parseEvents(item, eventIndex) {
//get the parent note for this entry
const entryDate=item.date.year +'-' + item.date.month +'-'+item.date.day;
const parentNoteId = api.getDateNote(entryDate).noteId;
item.images.forEach(function parseImages(image, imageIndex, images) {
const title= item.headline;
const note = api.createTextNote(parentNoteId, title, image.desc).note;
note.toggleRelation(false, "runOnAttributeChange");
note.tog…