JSON.Net Self referencing loop detected

前端 未结 11 809
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 04:18

I have a mssql database for my website within 4 tables.

When I use this:

public static string GetAllEventsForJSON()
{
    using (CyberDBDataContext d         


        
11条回答
  •  失恋的感觉
    2020-11-28 04:46

    I just had the same problem with Parent/Child collections and found that post which has solved my case. I Only wanted to show the List of parent collection items and didn't need any of the child data, therefore i used the following and it worked fine:

    JsonConvert.SerializeObject(ResultGroups, Formatting.None,
                            new JsonSerializerSettings()
                            { 
                                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                            });
    

    JSON.NET Error Self referencing loop detected for type

    it also referes to the Json.NET codeplex page at:

    http://json.codeplex.com/discussions/272371

    Documentation: ReferenceLoopHandling setting

提交回复
热议问题