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. }





原文地址:https://www.cnblogs.com/xiejunzhao/p/728222f170868b207bba1dcefae4a93f.html