go-json-experiment / json

Experimental implementation of a proposed v2 encoding/json package
BSD 3-Clause "New" or "Revised" License
340 stars 11 forks source link

Custom `format` Option #46

Open lmittmann opened 2 days ago

lmittmann commented 2 days ago

How can I handle a custom format option in an UnmarshalerV2?

dsnet commented 2 days ago

The intention of this feature was for it to be user-customizable. However, there are some gnarly questions regarding whether the format option is applicable to exactly the current value in the tree or the entire sub-tree. This is something that we can figure out after the initial release of v2.

You can watch our discussion on the topic at https://www.youtube.com/watch?v=sgWVtViFkBs&t=2668s.

lmittmann commented 13 hours ago

IMO the greatest v2 feature is the possibility to overwrite the (un)marshalling logic of types one does not control. But when one type can have more than one marshaling logic I need to fall back to type proxies again, like with v1.

From my understanding of the discussion you want that the format option only applies to "leaf"-keys. Is there already an existing prototype implementation of this?