Serializing into JSON using MemoryStream,while adding newlines C# -


i have serialize c# class data json. purpose use memorystream , 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 application produces output:

{"age":42,"arr":[{},{},{}],"name":"john","value":null,"w":{}} 

however, task have produce json file each entry entered in new line. example:

"somedata":[ {     "somedata" : "value",     "somedata" : 0,     "somedata": [         {             "somedata" : "value",             "somedata" : 0             ]         }     ] }, etc. etc. 

any ideas how can this? in advance!

ok, if want add code answered in question.

question here


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -