Skip to content

LitJson does not properly handle models that contain recursive public properties. Examples: Guid, DateTimeOffset #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kdprince opened this issue Aug 5, 2021 · 3 comments

Comments

@kdprince
Copy link

kdprince commented Aug 5, 2021

 public class ModelWithSelfReferenceProp
  {
      public ModelWithSelfReferenceProp()
      {
          RightNow = DateTime.Now;
      }
      public DateTimeOffset RightNow { get; }
  }

  [Fact]
  public void TestShouldNotThrowError()
  {
      var model = new ModelWithSelfReferenceProp();
      
      JsonMapper.ToJson(model);
      Assert.NotNull(model);
  }

Max allowed object depth reached while trying to export from type System.DateTimeOffset

Infinite recursion here: https://github.com/aws/aws-xray-sdk-dotnet/blob/master/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs#L828

This is most likely same issue as #202

@srprash
Copy link
Collaborator

srprash commented Jul 14, 2022

Fix for serializing GUID has been released in v2.11.0.

@srprash srprash closed this as completed Jul 14, 2022
@ehampusklarin
Copy link

OK it's fixed for Guid, but what about others such as DateTimeOffset, DateOnly, TimeOnly?

@jusbuc2k
Copy link

jusbuc2k commented Jul 27, 2023

Having this problem with booleans as well.

Max allowed object depth reached while trying to export from type System.Boolean

JsonMapper.WriteValue (/_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:828)
JsonMapper.WriteValue (/_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:828)
JsonMapper.WriteValue (/_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:765)
JsonMapper.WriteValue (/_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:765)
JsonMapper.ToJson (/_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:859)
JsonSegmentMarshaller.WriteEntityFields (/_/sdk/src/Core/Internal/Emitters/JsonSegmentMarshaller.cs:153)
JsonSegmentMarshaller.EntityExporter (/_/sdk/src/Core/Internal/Emitters/JsonSegmentMarshaller.cs:65)
<>c__DisplayClass38_0`1.<RegisterExporter>b__0 (/_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:919)
JsonMapper.WriteValue (/_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:790)
JsonMapper.ToJson (/_/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs:851)
JsonSegmentMarshaller.Marshall (/_/sdk/src/Core/Internal/Emitters/JsonSegmentMarshaller.cs:58)
UdpSegmentEmitter.Send (/_/sdk/src/Core/Internal/Emitters/UdpSegmentEmitter.cs:73)
DefaultStreamingStrategy.Stream (/_/sdk/src/Core/Strategies/DefaultStreamingStrategy.cs:80)
DefaultStreamingStrategy.Stream (/_/sdk/src/Core/Strategies/DefaultStreamingStrategy.cs:65)
DefaultStreamingStrategy.Stream (/_/sdk/src/Core/Strategies/DefaultStreamingStrategy.cs:65)
DefaultStreamingStrategy.Stream (/_/sdk/src/Core/Strategies/DefaultStreamingStrategy.cs:65)
AWSXRayRecorder.EndFacadeSegment (/_/sdk/src/Core/AWSXRayRecorder.netcore.cs:410)
AWSXRayRecorder.ProcessEndSubsegmentInLambdaContext (/_/sdk/src/Core/AWSXRayRecorder.netcore.cs:355)
AWSXRayRecorder.EndSubsegment (/_/sdk/src/Core/AWSXRayRecorder.netcore.cs:343)
XRayRecorder.EndSubsegment (undefined:undefined)
<WrapAsync>d__5`1.MoveNext (undefined:undefined)
ExceptionDispatchInfo.Throw (undefined:undefined)
TaskAwaiter.ThrowForNonSuccess (undefined:undefined)
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (undefined:undefined)
lambda_method3 (undefined:undefined)
UserCodeLoader.Invoke (/src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/UserCodeLoader.cs:145)
<>c__DisplayClass8_0.<GetHandlerWrapper>b__0 (/src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/HandlerWrapper.cs:55)
<InvokeOnceAsync>d__17.MoveNext (/src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs:208)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants