Home >Web Front-end >JS Tutorial >Detailed explanation of the steps to convert key-value string to json string
This time I will bring you the key value String Detailed explanation of the steps to convert the key value string to a json string. What are the precautions for converting the key value string to a json string? The following are Let’s take a look at practical cases.
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:
JS anonymous self-executing function concept and usage instructions
p5.js mouse interaction how to implement and use
vue Echarts implements click highlighting (with code)
How to deal with invalid Vue page DOM operations
Detailed explanation of the steps for vue1 and vue2 to obtain dom elements
The above is the detailed content of Detailed explanation of the steps to convert key-value string to json string. For more information, please follow other related articles on the PHP Chinese website!