How to export an object as json file in C#

Options
Valérie Gelbgras
Valérie Gelbgras Member, Employee Posts: 157
Name Dropper First Comment Photogenic First Anniversary

How to export an object as json file in C#

Tagged:

Answers

  • Valérie Gelbgras
    Valérie Gelbgras Member, Employee Posts: 157
    Name Dropper First Comment Photogenic First Anniversary
    Answer ✓
    Options

    Here is an example

    using (StreamWriter file = File.CreateText(@"c:\test.json"))
    {
        JsonSerializer serializer = new JsonSerializer();
        serializer.Serialize(file, modelObject);
     }