Home > Software engineering >  How can I add objects to a json file without ruining the format of the file?
How can I add objects to a json file without ruining the format of the file?

Time:11-17

I have a json file that I manually filled with information, and I want to add more to it using C#
I tried couple of things, but they ruined the format of the file

CodePudding user response:

I'm not a C# dev, but I may suggest you general advice:

  • read file and parse it as JSON object with any json parsing library available for C#.
  • put your data as new node to place where you want to modify.
  • convert it to string and rewrite the file. (the library may convert it to string by itself)

CodePudding user response:

How does addign more to it ruins the file? Can you share your C# class file and the code the transform the json to a file

  • Related