Commit 9e06b7c
authored
feat(data): enhance unmarshaler with JSON string to struct conversion (#1116)
Because
- YAML multiline strings containing JSON schemas (like `response-schema:
|`) could not be automatically converted to Go struct types like
`genai.Schema`
This commit
- Adds automatic JSON string → struct conversion capability to the core
unmarshaling framework
- Implements fast pre-check (`stringValue[0] == '{'` or `'['`) to avoid
unnecessary JSON parsing overhead on regular strings
- Adds `tryUnmarshalJSONString()` helper function that uses direct
`json.Unmarshal` to preserve complex nested structures1 parent 79630c0 commit 9e06b7c
2 files changed
+410
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
517 | 530 | | |
518 | 531 | | |
519 | 532 | | |
| |||
1192 | 1205 | | |
1193 | 1206 | | |
1194 | 1207 | | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
0 commit comments