Sunday, 7 May 2017

Parse JSON like dictionary from command line

I am trying to parse a JSON like dictionary from command line I want to pass something like

--myflags {'foo':'bar', 'foo2':bar2'}

When I use

var argv = require('minimist')(process.argv.slice(2));
console.dir(argv)

It reads the output as

3: --myflags
4: {'
5: foo':
6: 'bar',
7: 'foo2':
8: 'bar2'
9: }

var argv = require('minimist')(process.argv.slice(2)); console.dir(argv)

It reads the values as

 '{\'' }

How do i read the complete dicT?



via Illusionist

No comments:

Post a Comment