Home >Backend Development >C++ >How to Convert a JSON String to a C# DataTable?
Convert json strings to C# datatable
Convert the JSON string that indicates the data table to C# Datatable. Original JSON structure:
The expected datata output:
<code class="language-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} ]</code>
Simplified solutions:
<code>--------------------------------------------------------------------- ID | Name | Add | Edit | View | Authorize --------------------------------------------------------------------- 10 | User | false | true | true | true 11 | Group | true | false | true | false 12 | Permission| true | true | true | true</code>Compared to serialization of JSON to C#class, and then converting it into DataTable, there is a more direct method. You can use json.net to directly convert:
The above is the detailed content of How to Convert a JSON String to a C# DataTable?. For more information, please follow other related articles on the PHP Chinese website!