博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
小工具系列之json查看小工具
阅读量:5083 次
发布时间:2019-06-13

本文共 4689 字,大约阅读时间需要 15 分钟。

无聊写写代码玩玩,仿制firebug的json查看功能写的小工具,可用于非网页的JSON查看。

废话不多说,直接上图上代码 

json代码
[{"PID":1,"PName":"向城轩","AttentionCount":4,"Score":0,"Address":"上海市浦东新区茂兴路","proList":[],"PointX":13523723.5655,"PointY":3663540.2966,"IsProduct":false},{"PID":2,"PName":"韵泓筷子店","AttentionCount":1,"Score":0,"Address":"","proList":[],"PointX":13522930.5099,"PointY":3663762.6306,"IsProduct":false},{"PID":3,"PName":"家化中房苑","AttentionCount":1,"Score":0,"Address":"","proList":[],"PointX":13521716.2099,"PointY":3664131.6649,"IsProduct":false},{"PID":4,"PName":"上海沈工机电供应站","AttentionCount":1,"Score":0,"Address":"","proList":[],"PointX":13522749.0207,"PointY":3664046.4908,"IsProduct":false},{"PID":5,"PName":"上海张小泉刀剪总店","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522694.1534,"PointY":3663716.4823,"IsProduct":false},{"PID":6,"PName":"培罗蒙","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522644.7967,"PointY":3663838.1673,"IsProduct":false},{"PID":7,"PName":"停车场","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13523709.1033,"PointY":3663547.5709,"IsProduct":false},{"PID":8,"PName":"盘谷银行","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13523752.4223,"PointY":3663571.1879,"IsProduct":false},{"PID":9,"PName":"中国工商银行","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13523666.2735,"PointY":3663595.213,"IsProduct":false},{"PID":10,"PName":"广发银行","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13523043.7535,"PointY":3663513.642,"IsProduct":false},{"PID":11,"PName":"申华金融大厦","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13523352.434,"PointY":3664158.9574,"IsProduct":false},{"PID":12,"PName":"德兴馆","AttentionCount":6,"Score":0,"Address":"","proList":[],"PointX":13522483.4045,"PointY":3664060.1596,"IsProduct":false},{"PID":13,"PName":"福丹机电","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522451.553,"PointY":3664067.2636,"IsProduct":false},{"PID":14,"PName":"上海同缘烟草烟酒专卖","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522613.0783,"PointY":3663763.9579,"IsProduct":false},{"PID":15,"PName":"老客了酒楼","AttentionCount":1,"Score":0,"Address":"","proList":[],"PointX":13522609.7829,"PointY":3663775.1921,"IsProduct":false},{"PID":16,"PName":"虹庙旧木器商店","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522601.8907,"PointY":3663801.5225,"IsProduct":false},{"PID":17,"PName":"上海长江企业发展合租公司","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522602.1667,"PointY":3663814.223,"IsProduct":false},{"PID":18,"PName":"中国旅行社总社","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522605.4669,"PointY":3663827.1539,"IsProduct":false},{"PID":19,"PName":"BaleNo","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522578.4438,"PointY":3663680.5367,"IsProduct":false},{"PID":20,"PName":"NOKIA","AttentionCount":0,"Score":0,"Address":"","proList":[],"PointX":13522591.8576,"PointY":3663682.989,"IsProduct":false}]

[1,2,3,["a","b","c",["A","B","C"]]]

code其实很简单,如下:

///         /// 解析        ///         ///         ///         private void Jiexi(object obj, TreeNode node)        {            Type type = obj.GetType();            switch (type.Name)            {                case "Dictionary`2": //对象                    IDictionary
iDic = (IDictionary
)obj; node.Text += "(Object){   "; int c = 0; foreach (var o in iDic) { if (o.Value.GetType().Name != "Object[]" && c<3) { node.Text += o.ToString() + ","; } TreeNode t = new TreeNode(o.Key + ": "); node.Nodes.Add(t); Jiexi(o.Value, t); c++; } node.Text += "...}"; break; case "Object[]": //数组 IList ilist = (IList)obj; int i = 0; if (ilist == null || ilist.Count == 0) node.Text += " []"; foreach (var o in ilist) { TreeNode t = new TreeNode(i.ToString()); node.Nodes.Add(t); Jiexi(o, t); i++; } break; default: node.Text += "(" + type.Name + ")" + obj.ToString(); break; } }

转载于:https://www.cnblogs.com/mywaysoft/archive/2012/08/02/2619768.html

你可能感兴趣的文章
SQL语句在查询分析器中可以执行,代码中不能执行
查看>>
yii 1.x 添加 rules 验证url数组
查看>>
html+css 布局篇
查看>>
SQL优化
查看>>
用C语言操纵Mysql
查看>>
轻松学MVC4.0–6 MVC的执行流程
查看>>
redis集群如何清理前缀相同的key
查看>>
Python 集合(Set)、字典(Dictionary)
查看>>
获取元素
查看>>
proxy写监听方法,实现响应式
查看>>
第一阶段冲刺06
查看>>
十个免费的 Web 压力测试工具
查看>>
EOS生产区块:解析插件producer_plugin
查看>>
mysql重置密码
查看>>
jQuery轮 播的封装
查看>>
一天一道算法题--5.30---递归
查看>>
JS取得绝对路径
查看>>
排球积分程序(三)——模型类的设计
查看>>
python numpy sum函数用法
查看>>
php变量什么情况下加大括号{}
查看>>