Home > Web Front-end > JS Tutorial > JS method to convert key-value string to json string

JS method to convert key-value string to json string

php中世界最好的语言
Release: 2018-04-20 15:42:04
Original
1427 people have browsed it

This time I will bring you the key value String JS method to convert the key value string to json string, Precautions for converting the key value string to json string What are the following? This is a practical case, let’s take a look at it.

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("&","\",") + "\"}";
Copy after login
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

Vue references a separate style file

How js stores key values

The above is the detailed content of JS method to convert key-value string to json string. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template