JSON和GET请求字符串互转

JSON转GET请求参数

	sstr = {"a":"11","b":"12",}
   function json_to_get(sstr ){

	sstr = sstr.replace(/\t/g,"");
	sstr = sstr.replace(/\"/g,"").replace("{","").replace("}","").
    sstr = sstr.replace(",","&").replace(":","=");
	sstr = sstr.replace(/\"/g,"").replace(/{/g,"").replace(/}/g,"")
    sstr= sstr.replace(/,/g,"&").replace(/:/g,"=");
}

 GET转JSON请求参数:


function get_to_json(sstr){
  sstr = sstr.replace(/&/g,'","').replace(/=/g,'":"');
  sstr= '{"'+sstr+'"}';
}

猜你喜欢

转载自my.oschina.net/jamescasta/blog/1626396