问题描述
[{"licensePlate":"桂M99999","nextMaintenanceDate":"2016-01-12T00:00:00"},{"licensePlate":"桂M55555","nextMaintenanceDate":"2016-01-12T00:00:00"},{"licensePlate":"桂M77777","nextMaintenanceDate":"2016-01-12T00:00:00"}]前台:$("#bt_SendSMS").click(function(){varids=[];varrows=$('#TwoLevelMaintenanceSMS').datagrid('getSelections');vararr=null;varobj={};for(vari=0;i<rows.length;i++){arr={"licensePlate":rows[i].licensePlate,"nextMaintenanceDate":rows[i].nextMaintenanceDate}ids.push(arr);}$.post("/CustomService/SendNoticeSMS",JSON.stringify(result=ids),function(result){});});后台:publicActionResultSendNoticeSMS(){StreamReaderreader=newStreamReader(Request.InputStream);stringdata=reader.ReadToEnd();JavaScriptSerializerjs=newJavaScriptSerializer();varresult=js.DeserializeObject(data);这里什么遍历出result中的每个值?}
解决方案
解决方案二:
你用逗号,顿号split。
解决方案三:
引用1楼wyqlxy的回复:
你用逗号,顿号split。
+1
解决方案四:
你读到的data就是你一开始就写的字符串吗?如果是的话你就是到序列化成集合
解决方案五:
转化为对象,然后遍历
解决方案六:
如果用newtonsoft.json的话JArrayo=(JArray)JsonConvert.DeserializeObject(jsonstring);IList<JToken>oList=(IList<JToken>)o;foreach(JTokenjtinoList){JObjectjo=jtasJObject;foreach(Jpropertyjpinjo.Properties){获取json中的键jp.Name和值jp.Value}}