Repository navigation
Commit f748439
authored
[go] JSON deserialize Union fix (#1954)
Talked this through w/ @hellovai today, and this approach makes sense.
Walks the union variants and just tries to deserialize until it is
successful or fails completely.
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Implements JSON deserialization for union types in Go by attempting to
unmarshal each variant until successful, with tests added for
verification.
>
> - **Behavior**:
> - Implements `UnmarshalJSON` for union types in `types-unions.go.j2`
and `unions.go`.
> - Attempts to unmarshal each variant until successful, otherwise
returns an error.
> - **Tests**:
> - Adds test cases for `Union__float__bool` in `json_test.go` to verify
round-trip serialization and deserialization.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for b0d83d7. You can
[customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->1 parent 8074631 commit f748439
3 files changed
Lines changed: 673 additions & 31 deletions
File tree
- engine/language_client_codegen/src/go/templates
- integ-tests/go
- baml_client/types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
64 | 74 | | |
65 | 75 | | |
66 | 76 | | |
| |||
0 commit comments