node.js - how insert " in numbers of my json [NODEJS] -


i have json this:

{"name1":123,"name2":123,"name3":123}

i want put "" in numbers stay this:

{"name1":"123","name2":"123","name3":"123"}

anybody know nodejs code this?

as judson terrel saying above, should consider using json.stringify(myjsonobject)

but if desired use regex, here is

let str = '{"name1":123,"name2":123,"name3":123}'; let result = str.replace(/\b(\d+)/g, "\"$1\""); console.log (result);    //console-output =>  {"name1":"123","name2":"123","name3":"123"} 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -