Why does JSON.NET serialize everything on a single line?

后端 未结 2 1895
情深已故
情深已故 2021-01-02 05:46

I simply want the JSON.net serializer to write out JSON objects (to file), one object per line but instead it just appends everything on the same top line.

2条回答
  •  盖世英雄少女心
    2021-01-02 06:07

    Figured it out, though not sure if there's a cleaner way. I added a

    jw.WriteWhitespace(Environment.NewLine);
    

    at the end. Now everything looks good:

    {"TimeStamp":"2014-03-10T15:04:27.0128185",...}
    {"TimeStamp":"2014-03-10T15:04:27.0128185",...}
    ...

提交回复
热议问题