BurntSushi / toml

TOML parser for Golang with reflection.
MIT License
4.53k stars 527 forks source link

PrimitiveDecode and MetaData.PrimitiveDecode() should not be marked as deprecated. #404

Open shizhx opened 5 months ago

shizhx commented 5 months ago

This commit 4f8abaa marks both PrimitiveDecode and MetaData.PrimitiveDecode() as deprecated, but without these mechanisms, we would not be able to implement delayed parsing based on another field, which is the scenario described in #125. The Unmarshaler interface can't achieve the same effect because there's no type context.

To be honest, I think toml.Primitive is not as convenient as json.RawMessage because it requires holding the MetaData object for a long time.

arp242 commented 5 months ago

To be honest I never quite understood the use case for either PrimitiveDecode() or json.RawMessage. I'll have a closer look at the issue you linked and look up some more about json.RawMessage as well, and see what to do about it.

Either way, it's not going away until a potential v2, which may never materialize. So no hurries.

alexZaicev commented 1 month ago

@shizhx is there any update on the issue? Right now there is no way to parse any field based on type that is quite a common use-case