Convert all the integer value to string in JSON

前端 未结 3 1635
后悔当初
后悔当初 2020-12-16 19:57

My JSON string is:

{name:\"MyNode\", width:200, height:100}

I want to change it to:

{name:\"MyNode\", width:\"200\", height         


        
3条回答
  •  时光说笑
    2020-12-16 20:32

    If you must operate on the JSON string :

    json = json.replace (/:(\d+)([,\}])/g, ':"$1"$2');
    

提交回复
热议问题