edn2json

0.1.6 • Public • Published

edn2json

Convert EDN format to JSON format.

Build Status

Installation

sudo npm install -g edn2json # CLI. 
npm install edn2json # NodeJS. 

Usage

To use as CLI

edn2json [path-to-edn-input]

By default, it will output JSON with the same filename as the EDN file but with '.json' extension, which can be customized by:

edn2json [path-to-edn-input] -o [path-to-json-output]

To use in NodeJS

const parser = require('edn2json');
 
var ednString = '[{"foo" "bar"}]';
var data = parser.parse(ednString);
var jsonString = JSON.stringify(data); // [{"foo":"bar"}].

To use in browser

First install pegjs compiler and compile convert.pegjs:

sudo npm install -g pegjs
pegjs --format globals --export-var [variable-name] -o [path-to-js-output] convert.pegjs

Then in the HTML:

<!-- Suppose the js output is edn-parser.js and variable name is ednParser. -->
<script src="edn-parser.js"></script>
 
<script>
var ednString = '[{"foo" "bar"}]';
var data = ednParser.parse(ednString);
var jsonString = JSON.stringify(data); // [{"foo":"bar"}].
</script> 

Readme

Keywords

none

Package Sidebar

Install

npm i edn2json

Weekly Downloads

2

Version

0.1.6

License

MIT

Last publish

Collaborators

  • streaver91