I find it hard to figure out how to add an array of json objects to an existing JObject . Say I only have a JObject with a changed property, and I want to add another "IntersectGroups" property that contains an array of json objects, how can I do this? I have a JObject[] that when I serialize it exactly in the right format, but I'm looking for something like this: mainJObject.Add("IntersectGroups", myJObjectArray)
Here is an example of the final json I want when I serialize it.
... "Modified": "2012-11-26T10:21:04.693", "IntersectGroups": [ { "Id": 1004, "UserId": 20003, "GroupId": 1001, "Admin": false, "Expires": "1900-01-01T00:00:00" }, { "Id": 1003, "UserId": 20003, "GroupId": 1000, "Admin": false, "Expires": "1900-01-01T00:00:00" } ] ...
UPDATE
My final decision was to use a JArray object. JArray is a JContainer, which is a JToken that you can add to a JObject. My problem was that I was trying to use JObject [], which was not a valid JToken
bruchowski
source share