Ex:
let jsonArr = { "one", "two", "three" }
Can I modify to make it { "body": [ "one", "two", "three" ], "error": null }
using javascript
Ex:
let jsonArr = { "one", "two", "three" }
Can I modify to make it { "body": [ "one", "two", "three" ], "error": null }
using javascript
well, given that there's a typo, and instead of let jsonArr = { "one", "two", "three" }
you meant let jsonArr = [ "one", "two", "three" ]
, sure - why not?
let jsonArr = [ "one", "two", "three" ]
jsonArr = { body: jsonArr, error: null }
Your question should include the things you have tried.
You just need to build the new object.
e.g.
let jsonArr = [ "one", "two", "three" ]
const jsonObj = Object.assign({}, {
body: jsonArr,
error: null,
});