Passing rendered string to exec() doesn't escape ` " `

46 Views Asked by At

I have a nunjucks template. When I render it, I get the following string =>

something something '{"firstName": "john", "lastName": "doe", "age": 12}'

But when i pass it to exec() it's treated as =>

something something '{firstName: john, lastName: doe, age: 12}'

Is there a way to avoid that?

Sample code =>

function getCommand(){
    // render template
    return renderedString;
}

const command = getCommand();
exec(command);
0

There are 0 best solutions below