I solved this in some bizzaro way.  Maybe what is needed is a json parser
which is allowed to be multiple types.  Or, another way to think about
parsing which is easier on the type strictness, but still strongly typed.
Like a duck typed struct of some sort.  map[string]duck, where duck is
allowed to be map[string]duck.

On Thu, Sep 14, 2023 at 8:01 PM 'Jim Idle' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> You can also unmarshal in stages to Raw and then unmarshal the next piece
> based on what you have so far. I presume that you cannot change the format?
>
> On Fri, Sep 15, 2023 at 01:05 Tobias Klausmann <klaus...@schwarzvogel.de>
> wrote:
>
>> Hi!
>>
>> On Thu, 14 Sep 2023, Brian Candler wrote:
>> > Could you just unmarshal it to a map[string]IntTSList, and then walk it
>> and
>> > build whatever structure you want?
>>
>> I will try and make that work tomorrow, thanks for the hint!
>>
>> > If you want to pick certain fixed fields into a struct and separate out
>> the
>> > leftovers to be parsed as "subnet[X].Y", then see
>> >
>> https://stackoverflow.com/questions/33436730/unmarshal-json-with-some-known-and-some-unknown-field-names
>> > The last answer points to some other JSON libraries which can handle
>> this
>> > part for you - but you'd still have to process the "subnet[X].Y" keys.
>>
>> That looks like it might work as an alternative. I suspected that _some_
>> JSON lib out there would allow for "unknown at compile time" fields
>> (without resorting to [][]interface{} --- which leads to doing all the
>> parsing myself). So thanks for helping me find a blade of hay in a
>> needlestack :)
>>
>> Best,
>> Tobias
>>
>> --
>> 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/cf1b2521-79dc-4651-90de-afacff084f9a%40skade.local
>> .
>>
> --
> 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/CAGPPfg_0Rnu_RGASdKOgUQ9ccZdVz_4Rbo0Q%3D98vtziPWkiXFQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/golang-nuts/CAGPPfg_0Rnu_RGASdKOgUQ9ccZdVz_4Rbo0Q%3D98vtziPWkiXFQ%40mail.gmail.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/CAMyFqkSK%2BLq5yVpdbwmWjxTveuyOAaj3S4e6RSMgox-w9_K%3DLQ%40mail.gmail.com.

Reply via email to