JTurk14
JTurk14

Reputation: 3

Is it possible to put multiple data types into a JSON file?

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

Answers (1)

Fran
Fran

Reputation: 6530

Sure.

string json = JsonConvert.SerializeObject(new {integer = 1, list = drawList});
File.WriteAllText(@"C:\my\sample\path\package.json", json);

Upvotes: 2

Related Questions