I'm using Node.js v4.2.2 with ES6. I read a file that represents an object containing multiline strings. My file looks like:
{"a":`b
c`};
I read the file into a string:
var fs = require ('fs');
var my_string = fs.readFileSync(path_to_my_file).toString();
Finally, from that string I'd like to obtain the object that it represents. The only option I can find is using eval:
eval('my_object = ' + my_string);
is there another way? Note that JSON.parse(my_string)
is not an option because multiline strings are not part of JSON standard.