[QuestionDto [wentId=688, id=1, wenTi=one1, daAn=哎哟 不错 你答对了, daAn_div=null, fundcode=17A0SS], QuestionDto [wentId=689, id=2, wenTi=1213, daAn=2131312, daAn_div=null, fundcode=17A0SS]]
注: QuestionDto 是个数组
1
ETiV 2016-06-27 17:25:22 +08:00
正则
JSON.stringify( '[QuestionDto [wentId=123, id=1, wenTi=one1, daAn=哎哟 不错 你答对了, daAn_div=null, fundcode=XXXXXX]]' .match(/^\[QuestionDto \[(.*)\]\]$/)[1] .split(', ') .map(function(o){ o=o.split('='); var ret={}; ret[o[0]]=o[1]; return ret;})); |
3
smithtel OP @ETiV "[{"wentId":"688"},{"id":"1"},{"wenTi":"one1"},{"daAn":"哎哟 不错 你答对了"},{"daAn_div":"null"},{"fundcode":"17A0SS]"},{"QuestionDto [wentId":"689"},{"id":"2"},{"wenTi":"1213"},{"daAn":"2131312"},{"daAn_div":"null"},{"fundcode":"17A0SS"}]"
大概思路有了,我自己试下吧。 |