I’m using JSON.NET Linq to JSON, when I execute the below I get the following argument exception:
Can not add Newtonsoft.Json.Linq.JValue to Newtonsoft.Json.Linq.JObject
What’s wrong with the code
string content = new JObject(
new JObject("auth",
new JProperty("user", "anemail@gmail.com"),
new JProperty("secret", "somepassword")
),
new JObject("config",
new JProperty("template", "1")
),
new JObject("data",
new JProperty("email", "body")
)
).ToString();
As per the JSON.NET documentation, you need to wrap your JObjects in JProperties themselves: