Commit 6d4eb2b
authored
Fix Union JSON serialization (#1936)
This doesn't allow JSON deserialization (for that, some rust/runtime
work has to happen) but it does fix serialization to at least work one
way.
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Add JSON serialization support for union types in Go, with
`MarshalJSON` methods and a test file, but deserialization is not
implemented.
>
> - **Serialization**:
> - Add `MarshalJSON` method to union types in `types-unions.go.j2` and
`unions.go` for JSON serialization.
> - `UnmarshalJSON` method added but returns "not implemented" error.
> - **Testing**:
> - Add `json_test.go` to test JSON serialization round-trip.
> - Includes a commented-out test case for `Union__float__bool`
indicating incomplete functionality.
>
> <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 c216146. 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 b037124 commit 6d4eb2b
3 files changed
Lines changed: 606 additions & 1 deletion
File tree
- engine/language_client_codegen/src/go/templates
- integ-tests/go
- baml_client/types
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
50 | 66 | | |
51 | 67 | | |
52 | 68 | | |
| |||
0 commit comments