What you see in debugger when looking at the json
value is the string value that you should use in a C# file to obtain the same value.
Indeed you could replace
dynamic foo = new ExpandoObject();
foo.Bar = "something";
string json = Newtonsoft.Json.JsonConvert.SerializeObject(foo);
with
string json = "{\"Bar\":\"something\"}";
without changing the program's behaviour.
Thus, to obtain a different value, you should change how JsonConvert works, but JsonConvert conforms to the JSON standard, thus forget it!
If you are not actually serializing ExpandoObject (nor any other sealed class out of your control), you can use the DebuggerDisplayAttribute on the types that you are serializing in json, to define how the object will be shown during debug (in your code, the foo
instance).
But a string is a string and VisualStudio is right: double-quotes must be escaped.
SerializeObject
alone unless it's being serialized a 2nd time. If you're viewing the value within VS (via Locals, Watch, etc.), then it's rendering the value as code, but should have an option to view as text instead.