Skip to content

Commit

Permalink
Add 'dataRoot' to access the entire JSON file
Browse files Browse the repository at this point in the history
  • Loading branch information
farling42 committed Dec 5, 2023
1 parent adb2dbf commit 605056e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The importer will only read the first object from the supplied JSON file. (So wo

- SourceFilename: The name of the file which is supplying the data.
- SourceIndex: If the source data is an array (which is always the case for CSV files) this will be the index into the array, otherwise it will be the name of the field within the 'Field containing the data' object which is being used to create the current note.
- dataRoot: Is the entirety of the JSON file that was loaded (in case you need to access anything that is outside of the element currently being converted into a Note).

### Additional Handlebar Functions

Expand Down
1 change: 1 addition & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export default class JsonImport extends Plugin {
for (const [index, row] of entries) {
// Add our own fields to the ROW
row.SourceIndex = index;
row.dataRoot = objdata;
if (sourcefilename) row.SourceFilename = sourcefilename; // provide access to the filename from which the data was taken.

let notefile = objfield(row, settings.jsonName);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-import-json",
"name": "JSON/CSV Importer",
"version": "0.31.2",
"version": "0.32.0",
"minAppVersion": "1.1.15",
"description": "This plugin imports a JSON/CSV file (or text block) and creates notes from a Handlebars template file",
"author": "farling42",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-import-json",
"version": "0.31.2",
"version": "0.32.0",
"description": "This plugin imports a JSON/CSV file (or text block) and creates notes from a Handlebars template file",
"main": "main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.32.0": "1.1.15",
"0.31.2": "1.1.15",
"0.31.1": "1.1.15",
"0.31.0": "1.1.15",
Expand Down

0 comments on commit 605056e

Please sign in to comment.