Node querystring

const  qs =require('querystring');

var str="uname=tom&upwd=123&pno=33&kw=js;"

 //查询字符串转成对象

var obj=qs.parse(str);  

console.log(obj)    // 输出JS对象{uname:'tom'....}

console.log(obj.uname);    //输出字符串

//对象转成查询字符串

var obj2 = {ename:"强东",age:20,addr:"bj"};
var str = qs.stringify(obj2);
console.log(str);

 

posted @ 2017-08-10 08:14  ThisCall  阅读(118)  评论(0编辑  收藏  举报