Can struct field have two json keys?

Hello Gophers! I have a question for you. Lets say I receive 2 JSON types from same URL I’m requesting depending on query parameter. The difference between those two types is only one field for example:

{ type: "post" webURL: "www.example.com" text: "longer bla bla bla bla" } { type: "teaser" webURL: "www.example.com" description: "shorter bla " }

My question is is it possible to unmarshal those two jsons in same struct ? Like json:"key","alternativeKey".

Something like this, https://play.golang.org/p/JQ-le_8IP6, might work.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.