Home >Web Front-end >JS Tutorial >How to make js convert key value string to json string
This time I will bring you how to use js to convert the key value string into a json string, and js to convert the key value string into a json string Notes Yes Which ones, the following are practical cases, let’s take a look.
Key-value pair characters to be converted
var respDesc=“cardid=64157001&cardnum=1&sporder_id=PD12160428120635001&sporder_time=20160526101552”; var newstr = respDesc.replace("=",":\""); var stringObj= "{" +newstr.replace("&","\",") + "\"}";
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to php Chinese Other related articles online!
Recommended reading:
How to solve the error problem when Angular5 upgrades RxJS to 5.5.3
Angular entry components and declarative Comparison of component cases
#How to hot replace webpack modules
The above is the detailed content of How to make js convert key value string to json string. For more information, please follow other related articles on the PHP Chinese website!