zoukankan      html  css  js  c++  java
  • .net 读取json 文件

    原文:http://blog.csdn.net/w200221626/article/details/52169250

    json 文件 格式:

     1 {
     2     "total": 1,
     3     "page": 1,
     4     "records": 1,
     5     "costtime": "100",
     6     "rows": [
     7         {
     8             "rownum": 1,
     9             "userid": "888",
    10             "code": "8888",
    11             "account": "8888",
    12             "realname": "飞哥",
    13             "spell": "ZM",
    14             "gender": "",
    15             "mobile": "15201956999",
    16             "telephone": "021-88888888",
    17             "email": "qq@qq.com",
    18             "companyid": "10000",
    19             "companyname": "上海",
    20             "departmentid": "100001",
    21             "departmentname": "技术部",
    22             "duty": "工程师",
    23             "enabled": 1,
    24             "logoncount": null,
    25             "lastvisit": null,
    26             "sortcode": 9000,
    27             "createuserid": "admin",
    28             "remark": " "
    29         }
    30     ]
    31 }
    View Code

    读取 json 文件:

     1         public string GetFileJson(string filepath)
     2         {
     3             string json = string.Empty;
     4             using (FileStream fs = new FileStream(filepath, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite))
     5             {
     6                 using (StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("gb2312")))
     7                 {
     8                     json = sr.ReadToEnd().ToString();
     9                 }
    10             }
    11             return json;
    12         }
    View Code

    调用方法 :

    1 string filepath = Server.MapPath("~/json1.json");  
    2 string json = GetFileJson(filepath);  
    View Code
  • 相关阅读:
    Lucene 3.5 提供深度分页支持 searchAfter方法 方法的应用
    如何解决ORA12547错误
    sde 安装
    软件安装之arcsde10.0集群
    Linux 64bit下Oracle11g安装手册
    Lucene 3.5 提供深度分页支持 searchAfter方法 方法的应用
    Creating a Feature Set via C#
    sde 安装
    9.15
    9.18
  • 原文地址:https://www.cnblogs.com/caolingyi/p/8533451.html
Copyright © 2011-2022 走看看