javascript - How can I parse objects with multiline strings in ES6? -


i'm using node.js v4.2.2 es6. read file represents object containing multiline strings. file looks like:

{"a":`b       c`}; 

i read file string:

var fs = require ('fs'); var my_string = fs.readfilesync(path_to_my_file).tostring(); 

finally, string i'd obtain object represents. option can find using eval:

eval('my_object = ' + my_string); 

is there way? note json.parse(my_string) not option because multiline strings not part of json standard.

if don't eval expression, can throw es6 parser (like esprima) @ it, can manually , securely evaluate parts you're interested in.

but proper way not use object literals multiline template strings in first place, , store data json instead.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -