I want "data" to still have double quotes but i dont want double quotes wrapping data's value object. Note, "description" may have have a different number of characters each time. Finally, this will be used for 100+ items
I have this:
{"data": "{"id": 1, "name": "test", "description": "description with variable number of characters"}"}
I want this:
{"data": {"id": 1, "name": "test", "description": "description with variable number of characters"}}
remove the (") wrapping the id, name, description object
Use JSON.parse for parsing JSON data.
const data = `{"data": "{\\"id\\": 1, \\"name\\": \\"test\\", \\"description\\": \\"description with variable number of characters\\"}"}`;
let parsed = JSON.parse(data);
parsed.data = JSON.parse(parsed.data);
const result = JSON.stringify(parsed, null, 2);
console.log(result);