flattenRowValue extracts a plain Go value from a protojson RowValue oneof. Each value is a JSON object with exactly one key like {"stringValue": "x"}.
(raw json.RawMessage)
| 257 | // flattenRowValue extracts a plain Go value from a protojson RowValue oneof. |
| 258 | // Each value is a JSON object with exactly one key like {"stringValue": "x"}. |
| 259 | func flattenRowValue(raw json.RawMessage) any { |
| 260 | var m map[string]json.RawMessage |
| 261 | if json.Unmarshal(raw, &m) != nil { |
| 262 | return string(raw) |
| 263 | } |
| 264 | for key, val := range m { |
| 265 | if v, ok := unmarshalRowField(key, val); ok { |
| 266 | return v |
| 267 | } |
| 268 | } |
| 269 | return string(raw) |
| 270 | } |
| 271 | |
| 272 | // unmarshalRowField decodes a single protojson RowValue oneof field. |
| 273 | func unmarshalRowField(key string, val json.RawMessage) (any, bool) { |
no test coverage detected