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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -