Re: [go-nuts] Preserving extra properties using JSON unmarshal / marshal?

2020-02-24 Thread 'Eric Johnson' via golang-nuts
Thanks for the pointers. I was hoping for an easier answer. Maybe will look into patching stdlib. Eric. On Sat, Feb 22, 2020 at 1:15 AM Brian Candler wrote: > Looks like your thoughts are the right ones: > > https://stackoverflow.com/questions/33436730/unmarshal-json-with-some-known-and-some-

Re: [go-nuts] Preserving extra properties using JSON unmarshal / marshal?

2020-02-22 Thread Brian Candler
Looks like your thoughts are the right ones: https://stackoverflow.com/questions/33436730/unmarshal-json-with-some-known-and-some-unknown-field-names -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receivin

Re: [go-nuts] Preserving extra properties using JSON unmarshal / marshal?

2020-02-21 Thread 'Eric Johnson' via golang-nuts
Understand all that. It doesn't help. Asking the question a different way, as concrete code always clarifies. For something like the following snippet of code: const testJSON = `{ "first_name": "first", "last_name": "last", "favorite_color": "orange", "age": 92 }` func TestUnmarshalling(t *test

Re: [go-nuts] Preserving extra properties using JSON unmarshal / marshal?

2020-02-21 Thread Chris Burkert
Take a Look at https://blog.golang.org/json-and-go: The json package uses map[string]interface{} and []interface{}values to store arbitrary JSON objects and arrays; it will happily unmarshal any valid JSON blob into a plain interface{} value. The default concrete Go types are: - bool for JSON

[go-nuts] Preserving extra properties using JSON unmarshal / marshal?

2020-02-21 Thread 'Eric Johnson' via golang-nuts
If I've got a structure like this: type jsonData struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` } I can marshal / unmarshal JSON as: { "first_name": "first", "last_name": "last" } What if my input JSON is this: { "first_name": "first", "last_nam