I suggest that you use the DynamicJson to deserialize the JSON string and to obtain the data source of List<T> which can be shown on the GridView.
A sample code:
using System;
using System.Collections.Generic;
using System.IO;
using Codeplex.Data;
namespace DynamicJsonSample
{
internal class Program
{
static void Main(string[] args)
{
string filepath = @"C:\Users\surfe\Documents\Visual Studio 2022\CsProject\DynamicJson\DynamicJson\JsonFile.json";
string jsonText = "";
List<Item> list = new List<Item>();
using (StreamReader sr = File.OpenText(filepath))
{
jsonText = sr.ReadToEnd();
}
var json = DynamicJson.Parse(jsonText);
foreach (KeyValuePair<string, dynamic> kvp in json)
{
Item item = new Item
{
amount = kvp.Value.amount,
branch_num = kvp.Value.branch_num,
machineID = kvp.Value.machineID,
shift = (int)kvp.Value.shift,
userID = kvp.Value.userID,
voucher_date = DateTime.Parse(kvp.Value.voucher_date),
voucher_number = kvp.Value.voucher_number
};
list.Add(item);
}
}
}
public class Item
{
public string amount { get; set; }
public string branch_num { get; set; }
public string machineID { get; set; }
public int shift { get; set; }
public string userID { get; set; }
public DateTime voucher_date { get; set; }
public string voucher_number { get; set; }
}
Result: