Private JsonDataTable As New DataTable Private Sub SaveJson(ByVal FilePath As String) Dim Grouplist As New List(Of String) 'DataTableから列(グループ名)を取得 For Each Column As DataColumn In JsonDataTable.Columns Grouplist.Add(Column.ColumnName) Next Dim content As New Dictionary(Of String, Object) content.Add("list", New Dictionary(Of String, Object) From { {"grouplist", {Grouplist}} }) 'ここから動的にキーを追加したい For i As Integer = 0 To JsonDataTable.Columns.Count - 1 {Grouplist(i), {JsonDataTable.AsEnumerable().Select(Function(row) row(Grouplist(i))).ToArray()}} }) Next Dim jsonText As String = JsonConvert.SerializeObject(content, Formatting.Indented) Debug.WriteLine(jsonText) 'JSONをファイルに保存 Dim enc As Encoding = Encoding.UTF8 My.Computer.FileSystem.WriteAllText(FilePath, jsonText, False, enc) End Sub