May 10, 2013 at 1:19 PM
Edited May 10, 2013 at 1:20 PM
Prompted by your first line, I investigated Newtonsoft.Json a bit more. I now understand your confusion at my confusion!
I don't normally work with JSON but thought that nested types were done without escaping. Of course, that's only when they're serialized in one step. Doh! Put it down to a long day. :-(
I've changed the code that produced the above just to log SerializedException and to use JsonSerializerSettings with TypeNameHandling.All to record the Types being serialized, so that I can reconstitute them - this is supposed to be semantic logging, after
The following works (I've used EntityFramework to retrieve a trace record from the Logging.dbo.Traces table):
settings = new JsonSerializerSettings();
settings.TypeNameHandling = TypeNameHandling.All;
var trace = context.Traces.Where(t => t.id == 26).First();
var payload = trace.Payload;
var deserializedPayload = (JObject)JsonConvert.DeserializeObject(payload);
var serializedException =
var exception = JsonConvert.DeserializeObject(serializedException, settings);
but is it there another way to reconstitute it that would be considered better?
Or a different approach altogether?