-
-
Notifications
You must be signed in to change notification settings - Fork 32
Disable pointers when serializing? #288
Comments
Can you provide an example of when this happens, what you're getting, and what you expect, please? |
Sure. The following program produces the output (.Net Fiddle): If I remove the Equals & GetHashCode implementations I get the desired behaviour, but that isn't an acceptable solution for my code. using System;
public class Program
{
public static void Main()
{
var values = new Wrapper[] {new Wrapper { TheValue = "test"}, new Wrapper { TheValue = "test"}};
var serializer = new Manatee.Json.Serialization.JsonSerializer();
Console.WriteLine(serializer.Serialize(values).ToString());
}
}
public class Wrapper {
public string TheValue {get; set;}
public override bool Equals(object other) => other is Wrapper w && w.TheValue.Equals(this.TheValue);
public override int GetHashCode() => TheValue.GetHashCode();
} |
Yeah, send like the string serializer might be trying to use referential integrity. This can be turned off completely (might have implications for recursion detection), but it definitely shouldn't be doing that for strings. I'm not really maintaining this library anymore, though. If you like, you're welcome to submit a PR, and I'll review and merge it, but my focus has been on my new suite of libraries in the |
How do I turn it off? Recursion won't be an issue. |
Yeah, looks like I was mistaken. I thought there was a way to disable it, but it seems I didn't add that option. |
Is there functionality to prevent Manatee.Json from creating pointers when serializing? (or even just for specified types?). I'm serializing some objects with Equals implementations that are causing occasional identical values to be serialized with pointers, but the other side can't deal with them.
The text was updated successfully, but these errors were encountered: