I am trying to create a JObject on the fly for unit testing but it does not seem to like name.subname
as a property
The json that I am trying to create JObject for is
{ "UserDetails": {
"FirstName": "Test1",
"Surname": "Test2",
"UserID": "123456789",
"Children1.Active1": false,
"Children1.Active2": false
}
}
The C# code I have is
dynamic jsonObject = new JObject();
jsonObject.UserDetails = new JObject();
jsonObject.UserDetails.UserID = "123456789";
jsonObject.UserDetails.FirstName = "Test1";
jsonObject.UserDetails.Surname= "Test2";
However i am not sure how to add Children1.Active
to the JObject jsonObject. UserDetails
it does not work with jsonObject.UserDetails.Children.Active1 = false
.
I have validated the json and it passes validation for being valid json.
How can I add Children1.Active
to JObject?
I have tried jsonObject.UserDetails.Children1 = new JObject();
But this creates a new sub object which is not what I need.