问题描述
调用别人接口,服务器返回数据如下1。kd_callback("","1",[{"time":"2012-03-1515:11:00","context":"广东省揭阳市"},{"time":"2012-03-1514:40:35","context":"广东省揭阳市"},{"time":"2012-03-1512:47:13","context":"广东省汕头市"},{"time":"2012-03-1512:47:00","context":"广东省汕头市"},{"time":"2012-03-1423:48:05","context":"虎门分拨中心/下车扫描"},{"time":"2012-03-1423:47:56","context":"虎门"},{"time":"2012-03-1320:02:56","context":"浙江省杭州市"},{"time":"2012-03-1319:52:19","context":"浙江省杭州市"}])2。kd_callback("","1",[{"time":"2012-03-1514:54:08","context":"黑龙江省黑河市"},{"time":"2012-03-1513:49:39","context":"黑龙江省黑河市"},{"time":"2012-03-1412:57:19","context":"黑龙江省黑河市北安市"},{"time":"2012-03-1407:36:31","context":"黑龙江省黑河市"},{"time":"2012-03-1406:49:53","context":"黑龙江省黑河市"},{"time":"2012-03-1319:23:39","context":"哈尔滨"},{"time":"2012-03-1319:15:20","context":"哈尔滨"},{"time":"2012-03-1223:54:46","context":"杭州"},{"time":"2012-03-1222:43:30","context":"杭州"},{"time":"2012-03-1220:13:54","context":"浙江省杭州市"},{"time":"2012-03-1219:55:33","context":"浙江省杭州市"}])请问我怎么提取信息呢?我想要提取time和context的值!1。如:"time":"2012-03-1515:11:00","context":"广东省揭阳市"2。如:"time":"2012-03-1514:54:08","context":"黑龙江省黑河市"
解决方案
解决方案二:
这应该是json格式,网上有代码的
解决方案三:
我有找过JSON类了,解析不了
解决方案四:
引用2楼johnwanzhi的回复:
我有找过JSON类了,解析不了
简单的写了一下,不够完整,再改一改,不过能达到目的Regexreg2=newRegex("(?is)"time":"(?<time>(.*?))","context":"(?<context>(.*?))"");MatchCollectionmc=reg2.Matches(strfromtxt);foreach(Matchmeinmc){MessageBox.Show(me.Value);}
解决方案五:
引用3楼chinajiyong的回复:
引用2楼johnwanzhi的回复:我有找过JSON类了,解析不了简单的写了一下,不够完整,再改一改,不过能达到目的C#codeRegexreg2=newRegex("(?is)"time":"(?<time>(.*?))","context":"(?<context>(.*?))"");MatchColle……
+我Q:466791739