Json are simmilar to XML in terms of use but they are equivalent to txt file in terms of accessibility. you can use teh following code to read/write a jasoin file. you need to change the code as per your requirement.
READ :
var stream = File.OpenText("json file.txt");
string st = stream.ReadToEnd();
var jsonArray = JsonArray.Parse(st);
foreach (var item in jsonArray)
{
JsonObject ob = new JsonObject(item);
foreach (var t in ob.Values)
{
JsonObject oo = new JsonObject(t);
foreach (var x in oo)
{
textBox1.AppendText(x.Key + " : " + x.Value + "\n");
}
}
WRITE :
KeyValuePair<string, JsonValue> pair = new KeyValuePair<string, JsonValue>("FName","Sourabh");
KeyValuePair<string, JsonValue> pair2 = new KeyValuePair<string, JsonValue>("LName", "SInha");
List<KeyValuePair<string, JsonValue>> list = new List<KeyValuePair<string, JsonValue>>();
list.Add(pair);
list.Add(pair2);
JsonObject jObject = new JsonObject(list);
var stream = new StreamWriter("json out file.txt");
foreach (var x in jObject)
{
textBox1.AppendText(x.ToString() + "\n");
stream.WriteLine(x.ToString() + "\n");
}
JsonArray jarray = new JsonArray("item1","item2","Item3");
foreach (var x in jarray)
{
textBox1.AppendText(x.ToString());
stream.WriteLine(x.ToString());
}