Plug-in for Obsidian.md which will create Notes from JSON files

Overview

ko-fi patreon paypal Latest Release Download Count GitHub License

Import JSON

This plug-in provides you with the tools to import your favourite JSON tables.

A magnifying-glass icon will appear in the left margin when this plug-in is enabled.

Clicking the icon will open a dialog window with four fields:

  • "Choose JSON File" will allow to you pick any .json file.

  • "Choose TEMPLATE File" will allow you to choose any .md file, which should be a Handlebars template file (see https://handlebarsjs.com/guide/).

  • "JSON name field" will allow you to specify the JSON field within each row of the table which should be used as the name of the note.

  • "Set Folder" allows you to set the top-level folder name within your Vault into which all the notes will be placed.

When the IMPORT button is pressed then the JSON file will be read and all the notes created.

Note

If your Handlebars template file tries to reference something in the JSON data which isn't a simple text field, then the generated note will contain the text [object Object].

A notice will appear for each such note, but opening Obsidian's dev window (on MS Windows use Ctrl+Shift+i) will also show the list of affected notes.

Additional Handlebar Functions

When building handlebars template files, you will have access to all the handlebars-helpers provided at https://github.com/helpers/handlebars-helpers/

New Handlebar Functions

Table Lookup

A new inline helper "{{table" is available. It is used to lookup a value in a static look-up table and replace it with another value.

  • The first parameter is the value to be translated into another value.
  • value1 is the value to be compared to the lookup value.
  • result1 is the result of the {{table}} helper if the lookup value is equal to value1
  • value2 result2 = second set of possible matches
  • etc, as many pairs of value/result as you need. (any/all of the lookup value and value/result values can be fields or fixed strings)
{{!-- {{table "blue" "red" "angry" "blue" "sad" "yellow" "envious" "green" "happy"}}   --}}
{{!-- will be converted into the string 'sad'  (taking "blue" and looking for the value/result pair that matches) }}
{{table lookup value1 result1 value2 result2 value3 result3}}
Comments
  • #match with a regexp doesn't seem to work

    #match with a regexp doesn't seem to work

    I'm loading TSV data and when I attempt to use match from Handlebar-Helpers I get errors. What I'm trying to do is process a field into an array using a regexp then process the element of the array into a list using #each. I get nothing but errors when I try to use the following code:

    Stellar: 
    {{#each (match (Stars) (toRegex "[OBAFGKM]\d\s\w+|D|BD|BH|NS|PSR")) ~}}
    - {{this}}
    {{/each ~}}
    

    The field Stars contains data like:

    G0 V D
    F1 V D
    M3 V
    K6 II M2 V
    

    The regex is to unstring the multiple stars in the data field and put them on separate lines.

    help wanted 
    opened by ckennedy666 12
  • utils.createFrame is not a function

    utils.createFrame is not a function

    Thanks for the importer, I've finally got time to work through creating a template to import spells from 5etools. I'm attempting to use the forEach helper from handlebars-helpers library. During the import, I get the above error in the console. I've included the relevant block from my template below, as well as the json. Any ideas or suggestions as to what I'm doing wrong?

    Uncaught (in promise) TypeError: utils.createFrame is not a function
        at Object.helpers.forEach (eval at <anonymous> (app.js:1), <anonymous>:8078:24)
        at Object.wrapper2 (eval at <anonymous> (app.js:1), <anonymous>:1351:23)
        at Object.eval [as main] (eval at createFunctionContext (eval at <anonymous> (app.js:1)), <anonymous>:37:108)
        at main (eval at <anonymous> (app.js:1), <anonymous>:1534:36)
        at ret (eval at <anonymous> (app.js:1), <anonymous>:1537:16)
        at ret (eval at <anonymous> (app.js:1), <anonymous>:3373:25)
        at JsonImport.eval (eval at <anonymous> (app.js:1), <anonymous>:44334:20)
        at Generator.next (<anonymous>)
        at fulfilled (eval at <anonymous> (app.js:1), <anonymous>:36:24)
    
    {{#forEach entriesHigherLevel}}
    ## At Higher Levels
    
    {{entriesHigherLevel.0.entries}}
    {{/forEach}}
    
    [
    	{
    		"name": "Intellect Fortress",
    		"source": "TCE",
    		"page": 107,
    		"level": 3,
    		"school": "A",
    		"time": [
    			{
    				"number": 1,
    				"unit": "action"
    			}
    		],
    		"range": {
    			"type": "point",
    			"distance": {
    				"type": "feet",
    				"amount": 30
    			}
    		},
    		"components": {
    			"v": true
    		},
    		"duration": [
    			{
    				"type": "timed",
    				"duration": {
    					"type": "hour",
    					"amount": 1
    				},
    				"concentration": true
    			}
    		],
    		"entries": [
    			"For the duration, you or one willing creature you can see within range has resistance to psychic damage, as well as advantage on Intelligence, Wisdom, and Charisma saving throws."
    		],
    		"entriesHigherLevel": [
    			{
    				"type": "entries",
    				"name": "At Higher Levels",
    				"entries": [
    					"When you cast this spell using a spell slot of 4th level or higher, you can target one additional creature for each slot level above 3rd. The creatures must be within 30 feet of each other when you target them."
    				]
    			}
    		],
    		"damageResist": [
    			"psychic"
    		],
    		"damageImmune": [
    			"psychic"
    		],
    		"damageVulnerable": [
    			"psychic"
    		],
    		"miscTags": [
    			"SGT"
    		],
    		"classes": {
    			"fromClassList": [
    				{
    					"name": "Artificer",
    					"source": "TCE"
    				}
    			],
    			"fromClassListVariant": [
    				{
    					"name": "Bard",
    					"source": "PHB",
    					"definedInSource": "TCE"
    				},
    				{
    					"name": "Sorcerer",
    					"source": "PHB",
    					"definedInSource": "TCE"
    				},
    				{
    					"name": "Warlock",
    					"source": "PHB",
    					"definedInSource": "TCE"
    				},
    				{
    					"name": "Wizard",
    					"source": "PHB",
    					"definedInSource": "TCE"
    				}
    			]
    		},
    		"hasFluffImages": true
    	}
    ]
    
    enhancement 
    opened by AmbushXXVI 9
  • Please support TSV files as well

    Please support TSV files as well

    Is it possible to support Tab Separated Values (TSV)? This would be a great help in my attempt to import Traveller RPG sector data from TravellerMap.com in the https://travellermap.com/doc/fileformats#t5-tab-delimited-format.

    Thanks.

    enhancement 
    opened by ckennedy666 8
  • Textarea to paste JSON from clipboard

    Textarea to paste JSON from clipboard

    Thanks for the good work!

    What about a command to import from clipboard? Or a dialog with a text area to paste JSON (instead of choosing the JSON file)? This would simplify some two-step "export-import" workflows to bring data from other tools (like MS Outlook) to Obsidian...

    enhancement 
    opened by agnoldo 8
  • A question about

    A question about "Field to use as Note name"

    When opening the JSON CVS importer, I can define which field to use as Note name. However, how can I add @, for example, in front of the name?

    The field in JSON is citationkey. But, I want the name of a note as @citationkey.

    help wanted 
    opened by seed78 7
  • How to access the nested input objects?

    How to access the nested input objects?

    Hi, Thanks for developing such a nice plugin. I have a question about accessing the nested input objects in JSON file. I want to import "path" into a Obsidian template.

    I have tired {{attachments.path}}. But it doesn't work. Could you please tell me how to import "path" correctly?

    Thanks!

      "attachments": [
        {
          "dateAdded": "2022-06-25T16:22:45Z",
          "dateModified": "2022-06-25T16:23:05Z",
          "itemType": "attachment",
          "path": "C:\\folder\\file.pdf",
          "relations": [],
          "tags": [],
          "title": "file.pdf",
          "uri": "http://zotero.org/users/8045138/items/BSI5IT99"
        }
    
    question 
    opened by seed78 7
  • Use cases?

    Use cases?

    Sorry for opening an issue for my (simple) question/suggestion but the "discussion" module is not active for this repository. đŸ€·â€â™‚ïž

    My suggestion is that you spend a sentence for the use case of your plugin in the README.md file. That's because I thought I could use this plugin for my use case but I think I can't.

    My use case would be: I have a single JSON file which basically contains one array. The array contains dictionaries and inside these are key/value pairs I'd like to read and transform into one single markdown table in one single note (i.e. markdown file).

    Alas, in the README.md file I read about notes (plural) that get created from your plugin?! So I was wondering what the initial use case for your plugin was and if my use case could make use of your plugin at all? 😳

    question 
    opened by metawops 7
  • Empty folders, no notes

    Empty folders, no notes

    Hello! :) I know very little about coding and could be making a pretty obvious mistake! I keep getting a list of empty folders as opposed to notes. Any ideas for me to try? Thank you so much! Leonie

    help wanted 
    opened by PaySlipBanSA 6
  • table helper and regex substitution

    table helper and regex substitution

    I've been trying to work on some text replacement using regex in the body of an import, but I'm running into an issue. I've tried both of the below statements in my template, but neither of them works. They don't error, but the resulting text is not substituted. If I don't escape the single curly braces, I get an "incomplete quantifier" error in the console. Here is an example of the text as well as the regex find and substitute strings.

    {{table this (toRegex "\{@spell.(.*?)\}") (toRegex "[[$1]]")}} {{table this "\{@spell.(.*?)\}" "[[$1]]"}}

    Any help would be greatly appreciated and thanks again for the importer!

    enhancement 
    opened by AmbushXXVI 5
  • Can multiple values in one cell work?

    Can multiple values in one cell work?

    Say my CSV file is:

    name,value
    Alice,a
    Bob, "b,c,d" 
    

    And my template:

    {{name}}:: [[{{value}}]] 
    

    In Alice.md it returns Alice:: a as expected. But in Bob.md it returns Bob:: [[ &quot;b]]. Is it possible to have it return like this?

    Bob:: b
    Bob:: c
    Bob:: d
    
    question 
    opened by ooker777 5
  • add math helper?

    add math helper?

    Feature Request:

    Could you add the "math" helper?

    This StackOverflow seemed to have the same idea as I was thinking https://stackoverflow.com/questions/22103989/adding-offset-to-index-when-looping-through-items-in-handlebars

    relevant post: Actual answer: https://stackoverflow.com/a/46317662/1549191

    Register a math handlebar and perform all mathematical operations.

    app.engine('handlebars', exphbs({
      helpers:{
        // Function to do basic mathematical operation in handlebar
        math: function(lvalue, operator, rvalue) {lvalue = parseFloat(lvalue);
            rvalue = parseFloat(rvalue);
            return {
                "+": lvalue + rvalue,
                "-": lvalue - rvalue,
                "*": lvalue * rvalue,
                "/": lvalue / rvalue,
                "%": lvalue % rvalue
            }[operator];
        }
    }}));
    app.set('view engine', 'handlebars');
    
    Then you can directly perform operation in your view.
    
        {{#each myArray}}
            <span>{{math @index "+" 1}}</span>
        {{/each}}
    
    opened by rokville 4
  • a wish to use Hotkeys and an improved workflow

    a wish to use Hotkeys and an improved workflow

    Hi, I am a fan of using this plugin. I use it frequently to import bibliography from Zotero. I wonder whether it is possible to add the following two features.

    1. Is it possible to assign a hotkey for this plugin?
    2. This is related to my routine of using Zotero in the following steps.
      • I export my new bibliography in BetterBibTeX JSON file
      • From this same JSON file source, I need to use two different TEMPLATE files to import into two kinds of Notes that I need.
      • Each kind of Note uses the respective Destination Folder in Vault. As you can see from this procedure, I need to indicate the respective TEMPLATE files and Destination Folder in Vault for each kind of Note that I need from the same JSON file. These needs lots of clicking and switch between windows.

    A feature in my wish list for my point 2: Is it possible to indicate more than one template fileTEMPLATE files and its paired Destination Folder in Vault in order to import from the same JSON file?

    I summarize my wish as the following:

    1. Setup a "parallel import" workflow Same JSON file source ---> template 1 ----> Folder 1 ---> template 2 ----> Folder 2 ---> template N ---> Folder N
    2. Save this workflow as a workflow file
    3. can assign a HotKey for the indicated workflow

    The outcome of my wish is that as long as I export a JSON file, I simply use a HotKey for a particular workflow and then I will have more than one Note imported in the indicated folder simultaneously.

    Thanks again for considering this.

    opened by seed78 0
Releases(0.24.0)
Owner
Martin
Coding since 1980, or professionally 1987, on anything not MS-based
Martin
A Zotero add-on that scans your Markdown reading notes, tags the associated Zotero items, and lets you open notes for the Zotero items in Obsidian.

Zotero Obsidian Citations Adds colored tags to Zotero items that have associated Markdown notes stored in an external folder. Open an associated Markd

Dae 210 Jan 4, 2023
An Obsidian plugin for automatically creating notes when linking to non-existing notes

Note Auto Creator for Obsidian Automatically create notes when links are created to them. How to use After enabling the plugin in the settings menu, y

Simon Clement 31 Dec 14, 2022
A service for sharing encrypted Markdown notes from Obsidian. Notes are end-to-end-encrypted and are only stored temporarily.

?? Noteshare.space Noteshare.space is a service for sharing encrypted Markdown notes from Obsidian. Notes are end-to-end-encrypted and are only stored

Maxime Cannoodt 56 Dec 26, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till mÀnniskor pÄ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Obsidian Web: Connect your browser with your Obsidian notes

Obsidian Web: Connect your browser with your Obsidian notes This is an unofficial Chrome extension for Obsidian that lets you send content from the we

Adam Coddington 97 Jan 3, 2023
📝 You Can Create Your Own Short Notes With The Help of Sticky-Notes Website.

Hi ?? , I'm Sneh Agrawal A passionate Web developer from India ?? I’m currently working on Chatting Website Chit-Chat ?? How to reach me on My Gmail A

Sneh (Smilyboyy) 1 Feb 23, 2022
Obsidian plugin that allows user to create a glossary of files, an index of files or both.

Obsidian Auto Glossary Auto Glossary is an Obsidian plugin to create a glossary, an index or a glossary with an index from the files you want. Feature

Ennio Italiano 29 Dec 30, 2022
A plugin for Obsidian (https://obsidian.md) that adds a button to its search view for copying the Obsidian search URL.

Copy Search URL This plugin adds a button to Obsidian's search view. Clicking it will copy the Obsidian URL for the current search to the clipboard. T

Carlo Zottmann 6 Dec 26, 2022
Obsidian.md plugin to integrate with Zotero, create literature notes and insert citations from a Zotero library.

Obsidian Zotero Plugin Obsidian.md plugin to integrate with Zotero, create literature notes and insert citations from a Zotero library. Intro How to u

null 156 Jan 6, 2023
A plugin for Obsidian that can create input fields inside your notes and bind them to metadata fields.

Obsidian Meta Bind Plugin This plugin can create input fields inside your notes and bind them to metadata fields. New docs I am currently working on n

Moritz Jung 57 Jan 4, 2023
Easily publish notes to the web This plugin integrates with obsius.site to publish markdown notes on the web.

Obsius Publish Easily publish notes to the web This plugin integrates with obsius.site to publish markdown notes on the web. Limitations The type of c

Jon Grythe StĂždle 66 Dec 20, 2022
JCS (JSON Canonicalization Scheme), JSON digests, and JSON Merkle hashes

JSON Hash This package contains the following JSON utilties for Deno: digest.ts provides cryptographic hash digests of JSON trees. It guarantee that d

Hong Minhee (æŽȘ 民憙) 13 Sep 2, 2022
Add aliasing support to Vite from tsconfig.json or jsconfig.json files

Config to Alias Config to Alias adds aliasing support to Astro, JavaScript, TypeScript, and CSS files. Usage Install Config to Alias. npm install @ast

Astro Community 4 Mar 17, 2023
Piplup: decompile Playdate Pulp .pdx files back to .json project files

Piplup: decompile Playdate Pulp .pdx files back to .json project files This doesn't work yet: I still need to: convert the graphics (.pdt files) back

null 6 Mar 25, 2022
A Plugin which converts .md Files from Obsidian to your Kindle

Project 2: obsidian-kindle-export An Obsidian-Plugin which sends your Notes to your Kindle as .mobi File This is the exported .mobi File Introduction

Simerl 21 Dec 26, 2022
JSON Visio is data visualization tool for your json data which seamlessly illustrates your data on graphs without having to restructure anything, paste directly or import file.

JSON Visio is data visualization tool for your json data which seamlessly illustrates your data on graphs without having to restructure anything, paste directly or import file.

Aykut Saraç 20.6k Jan 4, 2023