Re: [go-nuts] How to define struct with defined properties that is also a map

2024-09-13 Thread twp...@gmail.com
Also, quick plug for https://github.com/twpayne/go-jsonstruct which will generate type-safe Go structs for you for all fields. Just throw a bunch of JIRA JSON responses at it. Regards, Tom On Friday, September 13, 2024 at 12:39:41 AM UTC+2 burak serdar wrote: > The current json implementation

Re: [go-nuts] How to define struct with defined properties that is also a map

2024-09-12 Thread burak serdar
The current json implementation in the stdlib does not support a catchall like that. Also, you cannot embed a map in a struct. You can replace JIRAFields with a map[string]any. If there are keys with known structures, you can do a map[string]json.RawMessage, and then you can do json.Unmarshal(fiel

[go-nuts] How to define struct with defined properties that is also a map

2024-09-12 Thread David Karr
This is probably basic, but I'm working on some code that unmarshals JIRA tickets (just for some context). Examining the Json output, there is a big "fields" object that mostly contains custom fields, but also some defined fields. Right now, I defined "Fields" as a "map[string]any", which is approp