How to export an object as json file in C#

Valérie Gelbgras
Valérie Gelbgras Member, Employee Posts: 156
Photogenic First Anniversary Ansys Employee Solution Developer Community of Practice Member

How to export an object as json file in C#

Tagged:

Answers

  • Valérie Gelbgras
    Valérie Gelbgras Member, Employee Posts: 156
    Photogenic First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓

    Here is an example

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