-
Notifications
You must be signed in to change notification settings - Fork 135
QuickJSONWrite
Cinchoo edited this page Jul 11, 2017
·
2 revisions
To generate JSON file, use the ChoJSONWriter component to generate it. Sample below shows how to create JSON file (Emp.json)
[
{
"Id":"1",
"Name":"Mark"
},
{
"Id":"2",
"Name":"Jason"
}
]
List<ExpandoObject> objs = new List<ExpandoObject>();
dynamic rec1 = new ExpandoObject();
rec1.Id = 1;
rec1.Name = "Mark";
objs.Add(rec1);
dynamic rec2 = new ExpandoObject();
rec2.Id = 2;
rec2.Name = "Jason";
objs.Add(rec2);
using (var parser = new ChoJSONWriter("Emp.json"))
{
parser.Write(objs);
}
using (var parser = new ChoJSONWriter("Emp.json"))
{
dynamic rec1 = new ExpandoObject();
rec1.Id = 1;
rec1.Name = "Mark";
parser.Write(item);
dynamic rec1 = new ExpandoObject();
rec1.Id = 2;
rec1.Name = "Jason";
parser.Write(item);
}
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
}
List<Employee> objs = new List<Employee>();
objs.Add(new Employee() { Id = 1, Name = "Tom" });
objs.Add(new Employee() { Id = 2, Name = "Mark" });
using (var parser = new ChoJSONWriter<Employee>("Emp.json"))
{
parser.Write(objs);
}
©2017 Cinchoo Inc