Convert EDN format to JSON format.
sudo npm install -g edn2json # CLI.
npm install edn2json # NodeJS.
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]
const parser = require('edn2json');
var ednString = '[{"foo" "bar"}]';
var data = parser.parse(ednString);
var jsonString = JSON.stringify(data); // [{"foo":"bar"}].
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>