I was wondering how to convert an array to an actual JSON object with keys and values. I am creating a Node.js command-line flag parser, and I would like to transform this:
[ '--input', 'HI!' ]
to this:
{ "--input": "HI!" }
as an example. JSON.stringify will not solve this problem, as JSON.stringify gives me this:
["--input","HI!"]
which is not what I want. If there is a way to solve this problem using JSON.stringify I am still open, but to my knowledge just using JSON.stringify will not solve this problem.
['a', 'b', 'c']?