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.peri...@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/ixVI5CzPqFP
>>
>> What 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:
> https://play.golang.org/p/1oDzdWlTCfC
> <https://play.golang.org/p/6G9ooLneADX>
>
>
> Manlio
>
>> 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+unsubscr...@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
> <https://groups.google.com/d/msgid/golang-nuts/274e489d-afdb-4ec9-a5b3-26440364c489%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CALWqRZomuBCB_vV84WA%3DHnsRS%2BfzYOA%2B_2hLyGQAA1BU4VfXtg%40mail.gmail.com.

Reply via email to