I have to serialize some C# class data into JSON. For this purpose I use a MemoryStream and a DataContractJsonSerializer.
MemoryStream stream1 = new MemoryStream();
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Person));
ser.WriteObject(stream1, p);
using (FileStream file = new FileStream("Write.json", FileMode.Create, FileAccess.ReadWrite))
{
    stream1.Position = 0;
    stream1.Read(stream1.ToArray(), 0, (int)stream1.Length);
    file.Write(stream1.ToArray(), 0, stream1.ToArray().Length);
    stream1.Close();
    file.Close();
}
Running the application like this produces this output:
{"age":42,"arr":[{},{},{}],"name":"John","value":null,"w":{}}
However, for my task I have to produce a JSON file where each entry is entered in a new line. Example:
"SomeData":[
{
    "SomeData" : "Value",
    "SomeData" : 0,
    "SomeData": [
        {
            "SomeData" : "Value",
            "SomeData" : 0
            ]
        }
    ]
}, etc. etc.
Any ideas as to how I can do this? Thanks in advance!
 
     
     
    