Reputation: 3
I am serializing and writing an Object List into a JSON file with this C# code:
string json = JsonConvert.SerializeObject(drawList);
File.WriteAllText(@"C:\my\sample\path\package.json", json);
Is it possible to also write an integer into this json file, and if so how should it be parsed so that the list and integer are separate?
Upvotes: 0
Views: 698
Reputation: 6530
Sure.
string json = JsonConvert.SerializeObject(new {integer = 1, list = drawList});
File.WriteAllText(@"C:\my\sample\path\package.json", json);
Upvotes: 2