js正则表达式和map转字符串转对象

"{HOME_ADDRESS_NEW=城关镇千东路社区, JKDAN_ID=4115280010216923, CARDID=413021196110180021, BLOODTYPE=null, NAME=何梅, DEATH_TYPE=0, AGE=57, RKLX=null, EDU_DEGREE=null, ROWNO=5, DELETE_TYPE=0, MEDICALID=413021196110180021, TELEPHONE_NUM=null, ZJ=1033192, MARRY_STATUS=null, VOCATION=null, SEX=女, BIRTH_DATE=1961-10-18, FORGID=248683, NATION=汉族, DATA_SOURCES=农合系统, ORGNAME=千东路社区}"

"{"HOME_ADDRESS_NEW=城关镇千东路社区, JKDAN_ID=4115280010216923, CARDID=413021196110180021, BLOODTYPE=null, NAME=何梅, DEATH_TYPE=0, AGE=57, RKLX=null, EDU_DEGREE=null, ROWNO=5, DELETE_TYPE=0, MEDICALID=413021196110180021, TELEPHONE_NUM=null, ZJ=1033192, MARRY_STATUS=null, VOCATION=null, SEX=女, BIRTH_DATE=1961-10-18, FORGID=248683, NATION=汉族, DATA_SOURCES=农合系统, ORGNAME=千东路社区}"


"{"HOME_ADDRESS_NEW=城关镇千东路社区, JKDAN_ID=4115280010216923, CARDID=413021196110180021, BLOODTYPE=null, NAME=何梅, DEATH_TYPE=0, AGE=57, RKLX=null, EDU_DEGREE=null, ROWNO=5, DELETE_TYPE=0, MEDICALID=413021196110180021, TELEPHONE_NUM=null, ZJ=1033192, MARRY_STATUS=null, VOCATION=null, SEX=女, BIRTH_DATE=1961-10-18, FORGID=248683, NATION=汉族, DATA_SOURCES=农合系统, ORGNAME=千东路社区"}"


"{"HOME_ADDRESS_NEW":"城关镇千东路社区, JKDAN_ID":"4115280010216923, CARDID":"413021196110180021, BLOODTYPE":"null, NAME":"何梅, DEATH_TYPE":"0, AGE":"57, RKLX":"null, EDU_DEGREE":"null, ROWNO":"5, DELETE_TYPE":"0, MEDICALID":"413021196110180021, TELEPHONE_NUM":"null, ZJ":"1033192, MARRY_STATUS":"null, VOCATION":"null, SEX":"女, BIRTH_DATE":"1961-10-18, FORGID":"248683, NATION":"汉族, DATA_SOURCES":"农合系统, ORGNAME":"千东路社区"}"

"{"HOME_ADDRESS_NEW":"城关镇千东路社区"," JKDAN_ID":"4115280010216923"," CARDID":"413021196110180021"," BLOODTYPE":"null"," NAME":"何梅"," DEATH_TYPE":"0"," AGE":"57"," RKLX":"null"," EDU_DEGREE":"null"," ROWNO":"5"," DELETE_TYPE":"0"," MEDICALID":"413021196110180021"," TELEPHONE_NUM":"null"," ZJ":"1033192"," MARRY_STATUS":"null"," VOCATION":"null"," SEX":"女"," BIRTH_DATE":"1961-10-18"," FORGID":"248683"," NATION":"汉族"," DATA_SOURCES":"农合系统"," ORGNAME":"千东路社区"}"

"{"HOME_ADDRESS_NEW":"城关镇千东路社区","JKDAN_ID":"4115280010216923","CARDID":"413021196110180021","BLOODTYPE":"null","NAME":"何梅","DEATH_TYPE":"0","AGE":"57","RKLX":"null","EDU_DEGREE":"null","ROWNO":"5","DELETE_TYPE":"0","MEDICALID":"413021196110180021","TELEPHONE_NUM":"null","ZJ":"1033192","MARRY_STATUS":"null","VOCATION":"null","SEX":"女","BIRTH_DATE":"1961-10-18","FORGID":"248683","NATION":"汉族","DATA_SOURCES":"农合系统","ORGNAME":"千东路社区"}"



" AGE": "57"
" BIRTH_DATE": "1961-10-18"
" BLOODTYPE": "null"
" CARDID": "413021196110180021"
" DATA_SOURCES": "农合系统"
" DEATH_TYPE": "0"
" DELETE_TYPE": "0"
" EDU_DEGREE": "null"
" FORGID": "248683"
" JKDAN_ID": "4115280010216923"
" MARRY_STATUS": "null"
" MEDICALID": "413021196110180021"
" NAME": "何梅"
" NATION": "汉族"
" ORGNAME": "千东路社区"
" RKLX": "null"
" ROWNO": "5"
" SEX": "女"
" TELEPHONE_NUM": "null"
" VOCATION": "null"
" ZJ": "1033192"
HOME_ADDRESS_NEW: "城关镇千东路社区"
__proto__: Object

替换代码

 

this.jkllq=function(row){
			/*var s1='{"HOME_ADDRESS_NEW":"城关镇千东路社区","ORGNAME":"千东路社区"}';
			var s2=JSON.parse(s1);
			var s3=s2.ORGNAME;*/
			
			/*var str=row;
			var reg=new RegExp('{','g');
			str=str.replace(reg,"{'");
			reg=new RegExp('}','g');
			str=str.replace(reg,"'}");
			reg=new RegExp('=','g');
			str=str.replace(reg,"':'");
			reg=new RegExp(',','g');
			str=str.replace(reg,"','")*/
			
			/*var s1={HOME_ADDRESS_NEW:"城关镇千东路社区",ORGNAME:"千东路社区"};
			var s2=s1.ORGNAME;*/
			
			
			var str=row;
			var reg=new RegExp('{','g');
			str=str.replace(reg,"{\"");//替换{
			reg=new RegExp('}','g');
			str=str.replace(reg,"\"}");//替换}
			reg=new RegExp('=','g');
			str=str.replace(reg,"\":\"");//替换:
			reg=new RegExp(',','g');
			str=str.replace(reg,"\",\"")//替换,
			reg=new RegExp('" ','g');
			str=str.replace(reg,"\"");//替换空格
			reg=new RegExp('null','g');
			str=str.replace(reg,"");//将null转换为空
			
			var toobj=JSON.parse(str);
			
			var myrow=document.getElementById("myTable").rows[1].cells;
			myrow[0].innerHTML=1;
			myrow[1].innerHTML=toobj.NAME;
			myrow[2].innerHTML=toobj.CARDID;
			myrow[3].innerHTML=toobj.MEDICALID;
			myrow[4].innerHTML=toobj.JKDAN_ID;
			myrow[5].innerHTML=toobj.SEX;
			myrow[6].innerHTML=toobj.BIRTH_DATE;
			myrow[7].innerHTML=toobj.HOME_ADDRESS_NEW;
			myrow[8].innerHTML=toobj.TELEPHONE_NUM;
				
			$("#rowshow").show();
			
		
			
		};

 

你可能感兴趣的:(javascript)