Friday 5 May 2017

Javascript unpack command line dictionary

I am learning javascript.

I am recieving a variable length of dictionary from the command line of the form

--myargs = {"foo":"bar", "foo2":"bar2"}

I can read the args by

var argv = require('minimist')(process.argv.slice(2));
console.dir(argv)
var myargs = argv["myargs"] 

I need to unpack the dictionary myargs like this->

my_new_args= {Key: "foo", Value: "bar", Key: "foo2", Value: "bar2" }; 

How do I do this in JS?



via Illusionist

No comments:

Post a Comment