C#/.NET/.NET Core应用程序编程开发中如何将JSON字符串中的集合转换成对应的DataTable呢?
2.64K 次浏览
在C#/.NET/.NET Core应用程序编程开发中,假如有一个集合类型的JSON字符串,现需要将这个集合转换成对应的DataTable,应该如何实现呢?
JSON示例如下:
[
{"id":"10","name":"User","add":false,"edit":true,"authorize":true,"view":true},
{"id":"11","name":"Group","add":true,"edit":false,"authorize":false,"view":true},
{"id":"12","name":"Permission","add":true,"edit":true,"authorize":true,"view":true}
]
期望得到的转换后的DataTable结构示例如下:
ID | Name | Add | Edit | View | Authorize |
---|---|---|---|---|---|
10 | User | true | true | true | true |
11 | Group | true | true | true | true |
12 | Permission | true | true | true | true |