我有一个来自我们客户关系管理系统的JSON文件:
[{"name": "erwin", "type":"ma", "id":"129"}, {"name": "hans", "type":"tf", "id":"12"}]
现在我需要按照ID值对该JSON进行排序,在我的例子中输出应为:
[{"name": "hans", "type":"tf", "id":"12"}, {"name": "erwin", "type":"ma", "id":"129"}]
我已经找到这个帖子:C# Sort JSON string keys
但我不知道如何将我的JSON文件加载到该解决方案的方法中。也许可以用json.net?问候,
弗朗西斯
编辑:
string sourcePath = @Settings.Default.folder;
string pathToSourceFile = Path.Combine(sourcePath, "myfile.json");
var list = JsonConvert.DeserializeObject<List<Gesamtplan>>(File.ReadAllText(pathToSourceFile));