C# 读取json文件并转为List集合

Posted on 2020-02-26 14:22  快醒醒  阅读(6373)  评论(0编辑  收藏  举报
  using (System.IO.StreamReader file = System.IO.File.OpenText(pathForSaving))
            {
                using (JsonTextReader reader = new JsonTextReader(file))
                {
                    JArray array = (JArray)JToken.ReadFrom(reader);
                    List<BelongingTo> belongingTos = array.ToObject<List<BelongingTo>>();
                    return belongingTos;
                }
            }

测试json文件为json数组

Copyright © 2024 快醒醒
Powered by .NET 9.0 on Kubernetes