c# 解析读取JSON文件


  1. using System;
  2. using Newtonsoft.Json;
  3. using System.IO;
  4. using Newtonsoft.Json.Linq;
  5. namespace SQLHelper {
  6. class Program {
  7. static void Main(string[] args) {
  8. string strReadFilePath = @"data.json";
  9. StreamReader srReadFile = new StreamReader(strReadFilePath);
  10. string jsonText = "";
  11. while (!srReadFile.EndOfStream) {
  12. jsonText += srReadFile.ReadLine();
  13. }
  14. JObject jo = (JObject)JsonConvert.DeserializeObject(jsonText);
  15. foreach (var i in jo.Values()) {
  16. Console.WriteLine(i["href"]);
  17. }
  18. }
  19. }
  20. }





posted @ 2017-07-02 18:27  xiejunzhao  阅读(2367)  评论(0)    收藏  举报