首页 新闻 会员 周边 捐助

提取json中的建的内容,正则表达式

0
悬赏园豆:20 [已关闭问题] 关闭于 2012-10-22 18:17
{ "_id" : "T_N0051", "Value" : { "AsScript" : "commands=[\"startTalk\",\"nextStep\"];\n\nnpc0=task.NPCBaseInfo[0];\nnpc1=task.NPCBaseInfo[1];\nscene=app.global[\"scene\"];\n\n\tstartTalk(){step=0;if(task.Status==1&&talkNPC==npc0.NPCID){talkPanel.Talk(\"<pcolor='fff799'bColor='753f1f'>恩,你需要帮我找一些有灵性的怪物过来抽取他们的技能,先找一个樱桃小木桩吧。</p>\",talkNPC,false);return;}if(task.Status==2&&talkNPC==npc1.NPCID){talkPanel.Talk(\"<pcolor='fff799'bColor='753f1f'>嗯嗯,就是它。</p>\",talkNPC,false);return;}}nextStep(){if(task.Status==1&&step==0&&talkNPC==npc0.NPCID){talkPanel.Talk(\"<pcolor='fff799'bColor='753f1f'>晕,你不要学我装记性不好,难道你真不知道要打樱桃小木桩么?</p>\",actorHead,false);step++;return;}if(task.Status==1&&step==1&&talkNPC==npc0.NPCID){talkPanel.dispose();return;}if(task.Status==2&&step==0&&talkNPC==npc1.NPCID){sendNotification(\"getAward\",task);talkPanel.dispose();return;}}", "Award" : [{ "Type" : 20001, "Name" : "Experience", "fz" : "", "GoodsID" : "", "Count" : 2800, "AwardID" : 0, "SelectType" : 0, "GoodsType" : "" }, { "Type" : 20001, "Name" : "PetExperience", "fz" : "", "GoodsID" : "", "Count" : 2800, "AwardID" : 1, "SelectType" : 0, "GoodsType" : "" }, { "Type" : 20001, "Name" : "Score", "fz" : "", "GoodsID" : "", "Count" : 1200, "AwardID" : 2, "SelectType" : 0, "GoodsType" : "" }], "BeginStatus" : 0, "Chufa" : [{ "TaskID" : ["T_N0043"] }], "ChufaType" : "TaskFinish", "CompositeType" : 0, "CreateDate" : "2011-07-05 15:01:37", "Description" : "米纳岸不听你的理由,说这是蓝依的占卜结果,你去找蓝依理论", "EndLoop" : "", "Finish" : [{ "Type" : 10008, "Cur" : 0, "Total" : 0 }], "LastHours" : 0, "Level" : 1, "LoopDate" : 1, "LoopTimesDay" : 0, "NPCBaseInfo" : [{ "Type" : 0, "NPCID" : "NPC_A0002", "NPCName" : "米纳岸", "NPCSceneID" : "MAP_A001", "NPCSceneName" : "凡海城" }, { "Type" : 1, "NPCID" : "NPC_A0037", "NPCName" : "蓝依", "NPCSceneID" : "MAP_A002", "NPCSceneName" : "寂寞沙滩" }], "NPCTalk" : "<si>\n  <talk p=\"getAward\" event=\"task,false\" status=\"0\" npcIcon=\"\" npc=\"0\">这可不关我老人家的事...这是你从蓝依那里的带回来的占卜结果上写的,就是灵石也是她给我的。如果你不信,可以去问蓝依。</talk>\n  <talk p=\"getAward\" event=\"task,true\" status=\"2\" npcIcon=\"\" npc=\"1\">你回来了?我就知道你会回来的。因为我是祭司。奥力奥力嗷~</talk>\n</si>", "RearTask" : "T_N0052", "StartLoop" : "", "TaskType" : 0, "TIMESTAMP" : "1329982372828", "traces" : "<si>\n  <i>去寂寞沙滩找蓝依理论占卜的结果</i>\n  <status v=\"0\">找凡海城的&lt;a click=\"findRoad\" event=\"NPC_A0002\"  SceneID=\"MAP_A001\" un=\"\"  color=\"00ff00\"&gt;米纳岸&lt;/a&gt;接受任务</status>\n  <status v=\"2\">去找寂寞沙滩的&lt;a click=\"findRoad\" event=\"NPC_A0037\"  SceneID=\"MAP_A002\" un=\"\"  color=\"00ff00\"&gt;蓝依&lt;/a&gt;询问占卜的事情</status>\n</si>", "UpdateDate" : "2012-02-23 15:32:52", "WeituoRenwu" : "{ShiChang:1000,}" }, "Name" : "质问蓝依", "MainType" : "Task", "SubType" : "", "UI" : null, "Author" : "192.168.100.201", "Modified" : ISODate("2012-05-15T03:17:12.614Z"), "Ver" : 2012042001 }

 

 

上面的json  我要获取字段内的内容 

写了如下正则表达式

 [^\\]".*?[^\\]"

提取的部分内容如下

"AwardID"

"SelectType"

"GoodsType"

"" }], "

最后一个就出现问题,"" }], " 字段双引号里面没有内容的就会把后面的东西也匹配出来,

求正则表达式高手支援下,功能其实就是想把所有json的键的内容给找出来 字符串的内容,其他内容可以不要

海不是蓝的主页 海不是蓝 | 初学一级 | 园豆:2
提问于:2012-07-23 14:45
< >
分享
所有回答(4)
0

既然是 json  为啥不用 对象的方式取呢 ?

张坤 | 园豆:1865 (小虾三级) | 2012-07-23 15:32
0

是用Javascript还是C#代码处理?

dudu | 园豆:30948 (高人七级) | 2012-07-23 15:42
0

不明白为何不直接转换后再取值?

Y2zz | 园豆:393 (菜鸟二级) | 2012-07-24 09:12
0

用对象的方式取

qsy | 园豆:22 (初学一级) | 2012-07-24 10:32
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册