1. 程式人生 > >js將鍵值對字串轉為json字串

js將鍵值對字串轉為json字串

要轉化的鍵值對字元

 var respDesc=“cardid=64157001&cardnum=1&sporder_id=PD12160428120635001&sporder_time=20160526101552

var newstr = respDesc.replace("=",":\"");    var stringObj= "{" +newstr.replace("&","\",") + "\"}";