前言
我是歌谣 今天给大家带来的是关于node中新版querystring模块的一个讲解
案例1
代码语言:javascript复制var str ="name=geyao&age=18&sex=nv"
var queryString=require("querystring")
var obj = queryString.parse(str)
console.log(obj)
运行结果
案例
代码语言:javascript复制var str ="name=geyao&age=18&sex=nv"
var queryString=require("querystring")
var obj = queryString.parse(str)
console.log(obj)
var myobj=queryString.stringify({
name:"geyao",
address:"suzhou",
age:18,
love:"hahh"
})
console.log(myobj)
运行结果
案例3
代码语言:javascript复制var str ="name=geyao&age=18&sex=nv"
var queryString=require("querystring")
var obj = queryString.parse(str)
console.log(obj)
var myobj=queryString.stringify({
name:"geyao",
address:"suzhou",
age:18,
love:"hahh"
})
console.log(myobj)
var geyao='id=3&data=北京&age=18&love=fangfang'
var escaped=queryString.escape(geyao)
console.log(escaped,"escaped is")
var escaped1="id=3&data=北京&age=18&love=fangfang"
var geyao1=queryString.unescape(escaped1)
console.log(geyao1,"geyao is")
运行结果
点个在看你最好看