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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -