Skip to content

QuickJSONLoad

Cinchoo edited this page Jul 1, 2017 · 5 revisions

Loading JSON file

To load JSON file, use ChoJSONReader component to parse it. Sample below shows how to load JSON file (Emp.json)

[
    {
    "Id": 1,
    "Name": "Mark"
    },
    {
    "Id": 2,
    "Name": "Tom"
    }
]

Load using iterator

foreach (dynamic e in new ChoJSONReader("Emp.json"))
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Load using loop

var reader = new ChoJSONReader("Emp.json");
dynamic rec;
 
while ((rec = reader.Read()) != null)
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Load using POCO object

public class Employee
{
    public int Id { get; set; }
    public string Name { get; set; }
}
foreach (var e in new ChoJSONReader<Employee>("Emp.json"))
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

For more information, please visit below article

Convert JSON to CSV file