thanks
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/274e489d-afdb-4ec9-a5b3-26440364c489%40googlegroups.com.
That sounds like a good plan. I'm going to try that. Thank you Manlio!
Am Di., 28. Apr. 2020 um 15:11 Uhr schrieb Manlio Perillo <manlio...@gmail.com>:
On Tuesday, April 28, 2020 at 10:52:56 AM UTC+2, Chris Burkert wrote:--Dear all,my application users shall be able to provide multiple json documents (files and urls) which I'd like to marshall into one structure. Additionally these json documents may have different versions. I know how to marshal a document into a version specific struct if I know the format version before (for simplicity of this example I don't handle errors): https://play.golang.org/p/ixVI5CzPqFPWhat I would like (in the example the village field was renamed to cities ) is a struct of type ModelV2 with all four values merged in Cities.Is there a best practice for a backwards compatible behavior which:
- identifies the json format version of each document
- skips that document if it is higher than the supported format version in my application
- merges supported format versions into ONE struct
Of course I have to implement the semantics on my own but how can I approach the topic?You can first unmarshal a struct containing only the Version field. As an example:Manliothanks
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.