Home >Web Front-end >JS Tutorial >Convert js key values ​​and characters to each other

Convert js key values ​​and characters to each other

php中世界最好的语言
php中世界最好的语言Original
2018-06-12 11:59:551650browse

This time I will bring you the mutual conversion of js key values ​​and characters. What are the precautions for the mutual conversion of js key values ​​and characters? The following is a practical case, 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:

Summary of techniques for using Angular one-way data flow

##keep-alive controls the number of server requests

Watchers, components and routing control in Vue.js

The above is the detailed content of Convert js key values ​​and characters to each other. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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