-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
The JsonNodeFactory instance always uses canonical instances for certain values of certain node types, including empty arrays, empty objects, ints from -1 to 10, booleans, maybe others.
I have a use-case where I need to parse a JSON/YAML file to a JsonNode
tree and use the nodes as keys in an IdentityHashMap. The canonical instances were, naturally, causing problems.
I've created my own factory and installed it in my mapper instances, and that works great. But I can't currently avoid canonical instances of BooleanNode
, NullNode
and MissingNode
, because none of them have a visible constructor (so I can't call the constructors, and I can't extend the types).
I don't actually have a need for non-canonical MissingNode
, and my inability to manufacture non-canonical boolean and null nodes is something I can live with (that prevents an unlikely edge-case for my application from working correctly, but I can document that and leave it as is for now).
Adding public constructors to these types would make it possible for me to complete my custom factory. Making existing constructors package-visible and adding a DeserializationFeature
that avoids canonical instances would probably be even better.