Skip to content

Cannot deserialize object that overrides GetHashCode() #128

Open
@jhughes2112

Description

I have a complex object that needs to have only two fields need to be considered for the sortable order of the object. So I override int GetHashCode() and return a hash code constructed of those two fields. I get an exception here:

In ParseDictionary:
JSON.cs (725) at "_circobj.TryGetValue(o, out circount) == false)"

o does not have any members set yet, so it dereferences null while calculating the hash for the object. I suppose I could provide a constructor, but the hash code would be meaningless at that point. I'm guessing this is how you handle circular references?

I "solved" this issue by taking the block at 725 and moving it just before the return, although I'm not certain it still works as you intended this way.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions