How to add JArray
into JObject
? I am getting an exception when changing the jarrayObj
into JObject
.
paramete
// array of animals
var animals = new[] { "cat", "dog", "monkey" };
// our profile object
var jProfile = new JObject
{
{ "birthday", "2011-05-06" },
{ "email", "dude@test.com" }
};
// Add the animals to the profile JObject
jProfile.Add("animals", JArray.FromObject(animals));
Console.Write(jProfile.ToString());
Outputs:
{
"birthday": "2011-05-06",
"email": "dude@test.com",
"animals": [
"cat",
"dog",
"monkey"
]
}