https://github.com/elivlo/empty
A simple type for JSON to marshall empty lists as square brackets
https://github.com/elivlo/empty
Last synced: 3 months ago
JSON representation
A simple type for JSON to marshall empty lists as square brackets
- Host: GitHub
- URL: https://github.com/elivlo/empty
- Owner: elivlo
- License: mit
- Created: 2024-06-28T14:17:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-02T21:30:41.000Z (over 1 year ago)
- Last Synced: 2025-03-30T00:41:44.657Z (9 months ago)
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## empty [](https://godoc.org/github.com/elivlo/empty)
`import "github.com/elivlo/empty"`
empty is a library to only supports marshalling empty lists with square brackets instead of null.
This type won't be needed for communication between Go services but helps a lot with Pydantic in Python.
There is no need for declaring a type in python as `Optional` with this package.
#### Interfaces
- All types also implement `json.Marshaler` and `json.Unmarshaler`, so you can marshal them to their native JSON representation.
#### empty.List[`T`]
Represents a slice of type T.
It marshals an empty list to brackets `[]` instead of `null` but unmarshalls like a normal slice.
### License
MIT