1

Closed

Can not add Newtonsoft.Json.Linq.JValue to Newtonsoft.Json.Linq.JObject.

description

Hi, today I noticed, maybe, a bug, that is generated when I try to serialize a JObject created from its constructor. Here is the code(it is C#):

In this way it works:
var json = new JObject();
json["Test"] = "test";
var jraw = new JRaw(json.ToString(Formatting.None));
var serialized = JsonConvert.SerializeObject(jraw);
On the contrary, if I try to do this:
var json = new JObject {"Test", "test"};
var jraw = new JRaw(json.ToString(Formatting.None));
var serialized = JsonConvert.SerializeObject(jraw);
I get the exception in the title.

Is it a bug? Or is it voluntary?
Thanks :)
Closed Jan 22, 2013 at 7:57 AM by JamesNK
This is attempting to add strings directly to a JObject: new JObject {"Test", "test"}

comments