This project has moved and is read-only. For the latest updates, please go here.


PreserveReferencesHandling.None not working properly?


I've already looked at how to remove referencing between same instance objects during JSON serialization but all the answers I've seen simply tell me to set the PreserveReferencesHandling to None, which I have done but the output STILL has references to same instance objects.

Here is my code:

return JsonConvert.SerializeObject(target, new JsonSerializerSettings {
NullValueHandling = NullValueHandling.Include,
PreserveReferencesHandling = PreserveReferencesHandling.None,
ContractResolver = new CustomContractResolver(),
Converters = CustomConverters

The output from this is still coming out with $id's and $ref's, BUT, only on Entity Framework objects, is this by design? If so, is there any way to prevent those $id's and $ref's on Entity Framework objects?
Closed Oct 3, 2013 at 11:02 AM by JamesNK
Write a custom contract resolver