I would like to know how to convert the input json array to a json object in the expected format using Javascript
Here is my input array
[
{
"Id": 1,
"Name": "One"
},
{
"Id": 2,
"Name": "Two"
},
{
"Id": 3,
"Name": "Three"
}
]
Expected json object output
{ "1" : "One",
"2" :"Two",
"3" :"Three"
}
id
as the property names/keys.JSON
, you are implicitly saying that your input and expected output will be strings. Maybe you just want to know how to convert array of objects to a single object.Id
entries are numbers in the first structure and become strings in your expected result...