This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9076|Reply: 1

[JavaScript] JS stitches JSON-formatted objects into complex URL parameter methods

[Copy link]
Posted on 6/4/2019 9:52:40 AM | | |
//调用:

var obj={name:'tom','class':{className:'class1'},classMates:[{name:'lily'}]};

parseParam(obj);

Result: "name=tom&class.className=class1&classMates[0].name=lily"

parseParam(obj,'stu');

Result: "stu.name=tom&stu.class.className=class1&stu.classMates[0].name=lily"

Convert string to a json object

var   define   =   "{name: 'Michael ',email: '17bity@gmail.com '} ";
var   data   =   eval( '( '   +   define   +   ') ');
alert(data.name);

The above JS method of splicing JSON format objects into complex URL parameters is all the content shared by the editor





Previous:E-book resource "Quantitative Ecology - Application of R Language Lai Jiangshan"
Next:Angular questions about getting Matrix URLs and normal URL query strings
 Landlord| Posted on 6/4/2019 9:53:14 AM |
Stitch an object after the URL

Parse the URL to get the parameter object



Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com