Skip to content

Conversation

sudison
Copy link
Contributor

@sudison sudison commented Jul 1, 2025

This is based on #2255, not sure github is able to handle stacked PRs.

sudison added 3 commits June 29, 2025 20:02
- Add json_marshal.c3 with Go-style API (json::marshal, json::marshal_value, json::marshal_array)
- Support all primitive types: String, int, float, double, bool
- Support enums (always marshaled as enum names, regardless of associated values)
- Support nested structs and arrays of any supported type
- Use temp allocator for memory-safe operation
- Comprehensive test suite with 15 test cases covering all features
- Follow C3 coding style with proper  and kindof usage
- Extract common marshaling logic into marshal_value function
- Simplify marshal() to use marshal_value for all struct fields
- Simplify marshal_array() to use marshal_value for all array elements
- Add array/slice support to marshal_value function
- Reduce code duplication by ~60 lines while maintaining all functionality
- All existing tests continue to pass
- Add unmarshal() function to convert JSON strings to structs
- Support for all primitive types (int, float, bool, String)
- Support for enums (by name lookup)
- Support for nested structs
- Support for arrays and slices
- Strict type checking with appropriate JSON number handling
- Comprehensive test coverage with 40 passing tests
- Clean API design following Go-style naming conventions
@sudison sudison closed this Jul 1, 2025
@sudison sudison deleted the json-unmarshal branch July 1, 2025 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant