JsonSerializationException: Self referencing loop

  1. #1

    JsonSerializationException: Self referencing loop

    My entities are double-sided reference
    and I set IgnoreAttribute for back reference properties

            [System.Xml.Serialization.XmlIgnoreAttribute()]
            [System.Web.Script.Serialization.ScriptIgnoreAttribute()]

    but i got Exception on serialization still

    Newtonsoft.Json.JsonSerializationException: Self referencing loop
    How do I?
  2. #2

    RE: JsonSerializationException: Self referencing loop

    Hi,

    Use the following attribute
    Newtonsoft.Json.JsonIgnoreAttribute
    *
  3. #3

    RE: JsonSerializationException: Self referencing loop

    It works,thanks
  4. #4

    RE: JsonSerializationException: Self referencing loop

    Hi,
    I'm having the same problem. Which declare theNewtonsoft.Json.JsonIgnoreAttribute
    Grid
    <ext:Store ID="StoreExposicao" runat="server" AutoLoad="true" OnRefreshData="RefreshData1" RefreshAfterSaving="Auto" SerializationMode="Complex" >
                <Reader>
                    <ext:JsonReader ReaderID="expId">
                        <Fields>                        
                            <ext:RecordField Name="expId"/>                        
                            <ext:RecordField Name="expIdCnr"/>     
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
    Grid.cs
            protected void AtualizarGrid()
            {
                List<Exposicao> l = ExposicaoController.Retornar();
                this.StoreExposicao.DataSource = l;
                this.StoreExposicao.DataBind();
            }
    Class Exposicao
    
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Canoro.Model;
    using NHibernate;
    using Castle.ActiveRecord;
    
    namespace Canoro.Model
    {
        [ActiveRecord("exposicao")]
        public partial class Exposicao : ActiveRecordBase<Exposicao>
        {
            #region private fields
    
            private int? _expId;
            private Canario _expIdCnr;
            private string _expIQR;
            private double _expPreco;
            private int? _expPontos;
            private int? _expClassificacao;        
    
            #endregion
    
            public Exposicao() { }
    
            #region public properties
            [PrimaryKey(PrimaryKeyType.Native, "expId")]
            public int?  expId
            {
                get { return _expId; }
                set { _expId = value; }
            }
            [OneToOne]
            public Canario expIdCnr
            {
                get { return _expIdCnr; }
                set { _expIdCnr = value; }
            }
    
            [Property("expIQR")]
            public string expIQR
            {
                get { return _expIQR; }
                set { _expIQR = value; }
            }
            [Property("expPreco")]
            public double expPreco
            {
                get { return _expPreco; }
                set { _expPreco = value; }
            }
            [Property("expPontos")]
            public int? expPontos
            {
                get { return _expPontos; }
                set { _expPontos = value; }
            }
            [Property("expClassificacao")]
            public int? expClassificacao
            {
                get { return _expClassificacao; }
                set { _expClassificacao = value; }
            }
    
            #endregion
            #region Consultas
            public static List<Exposicao> FindAllExposicao()
            {
                Exposicao[] a = (Exposicao[])FindAll(typeof(Exposicao));
                List<Exposicao> c = a.ToList();
                return c;
            }
    
            public static Exposicao FindById(int id)
            {
                return (Exposicao)FindByPrimaryKey(typeof(Exposicao), id);
    
            }
    
            #endregion
        }
    }
  5. #5

    RE: JsonSerializationException: Self referencing loop

    in class "Canario "

    set the "Newtonsoft.Json.JsonIgnoreAttribute" for all properties if the type of property is "Exposicao"

Similar Threads

  1. Replies: 6
    Last Post: Aug 13, 2013, 5:59 AM
  2. Replies: 1
    Last Post: Sep 15, 2011, 4:31 PM
  3. [CLOSED] [1.0] Referencing User Controls using #{}
    By bsnezw in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 15, 2010, 10:59 AM
  4. [CLOSED] Gray theme css referencing default folder
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 05, 2008, 8:08 PM

Posting Permissions