You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Looking at this issue opened with our repo, I realized that LitJSON doesn't handle serializing Guid type very well and throws the following error:
Unhandled exception. LitJson.JsonException: Max allowed object depth reached while trying to export from type System.Guid
at LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in C:\projects\litjson\src\LitJson\JsonMapper.cs:line 725
at LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in C:\projects\litjson\src\LitJson\JsonMapper.cs:line 861
at LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in C:\projects\litjson\src\LitJson\JsonMapper.cs:line 861
at LitJson.JsonMapper.WriteValue(Object obj, JsonWriter writer, Boolean writer_is_private, Int32 depth) in C:\projects\litjson\src\LitJson\JsonMapper.cs:line 861
More details along with a repro code are on the issue. Let me know if there's a way to handle Guid without special casing. Would be happy to do a PR. Thanks!
The text was updated successfully, but these errors were encountered:
I believe the general case involves models that contain public properties that are recursive.
Here's a System.Runtime type that defines a recursive structure
public readonly struct DateTimeOffset
{
/// Recursive properties below
public static DateTimeOffset UtcNow { get; }
public static DateTimeOffset Now { get; }
}
Example:
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
Hi,
Looking at this issue opened with our repo, I realized that LitJSON doesn't handle serializing Guid type very well and throws the following error:
More details along with a repro code are on the issue. Let me know if there's a way to handle Guid without special casing. Would be happy to do a PR. Thanks!
The text was updated successfully, but these errors were encountered: