You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this code which might allow me to use JSON strings as parseable option values
the syntax that works is:
--match='["a","b","c"]'
the patchwork code that I have added to my project looks like:
varparser=dashdash.createParser({options: options});varopts=parser.parse(process.argv);console.log('opts before => ',util.inspect(opts));options.filter(function(opt){returnString(opt.type).startsWith('arrayOf');}).forEach(function(opt){constn=String(opt.name||opt.names[0]).replace('-','_');if(ninopts){opts[n]=_.flattenDeep(opts[n].map(function(item){console.log('item => ',util.inspect(item));try{return_.flatten([JSON.parse(item)]);}catch(err){returnitem;}}));}});console.log('opts after => ',util.inspect(opts));
JSON.parse would allow any content inside the string, be it undefined, null, a number, a single string, an object or an array (of any even mixed values of the above).
Since it's more then trivial to support a custom typejson:
I have this code which might allow me to use JSON strings as parseable option values
the syntax that works is:
--match='["a","b","c"]'
the patchwork code that I have added to my project looks like:
but what I get is:
looks like to make sure this goes bug free, that I would need library support for this, because the _order property needs to match I assume.
My best guess is for this type of support is to do:
if useJSON was true, then JSON.parse would be called for each item
The text was updated successfully, but these errors were encountered: