I am using an API, which returns a field that is sometimes a boolean, sometimes a string.
like this:
{
"unstable":true,
"unstable_reason":"ANY_REASON"
}
and
{
"unstable":false
"unstable_reason":false
}
the struct looks like this:
...
Unstable bool `json:"unstable"`
UnstableReason string `json:"unstable_reason,string"`
...
When trying to use this, I get the following error:
panic: json: invalid use of ,string struct tag, trying to unmarshal unquoted value into string
On the other hand, when using bool for UnstableReason, an error occurs aswell.
When removing ,string, I get this error:
panic: json: cannot unmarshal bool into Go struct field .data.prices.unstable_reason of type string
The field is not relevant for my purposes, so if there is a way to just let it be nil, this would also be fine.
I have no impact on the API.
Any Ideas? I am relatively new to go.