Ofcourse I don't know excactly what your list contains, but have you tried adding the following?
return JsonConvert.SerializeObject(results, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
Hi There,
When i add the ReferenceLoopHandling i receive this error:
[NullReferenceException: Object reference not set to an instance of an object.]
EPiServer.Core.PropertyContentReference.get_ID() +13
GetID(Object ) +44
Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target) +383
[JsonSerializationException: Error getting value from 'ID' on 'EPiServer.Core.PropertyPageReference'.]
I would like to add also that the ID is not null. It has value. And that the same code is working in EpiServer 8.
Have you tried adding
NullValueHandling = NullValueHandling.Ignore
to the settings as well?
Jeroen, Thanks for the fast reply.
I still get the NullReferenceException even after having NullValueHandling ignored in the settings. This is really strange.
Sorry to rekindle an old thread but did you get this working? I see that the GetID doesn't do a null check in their code.
Hi
Migrating to EPiServer 10 is causing Circular reference in all JSON Serializations i use.
whether i use JavascriptSerializer, Newtonsoft, Jil.. i get a circular reference error while serializing a list of PageTypes.
I can loop through the objects and get the properties i only need and build a JSON. But this is a huge project that serializes objects lots of times. so rewriting the code seems almost impossible.
Any idea how to solve that?