https://github.com/crawshaw/jsonfile
Persist a Go object to a JSON file
https://github.com/crawshaw/jsonfile
Last synced: 10 months ago
JSON representation
Persist a Go object to a JSON file
- Host: GitHub
- URL: https://github.com/crawshaw/jsonfile
- Owner: crawshaw
- License: bsd-3-clause
- Created: 2024-02-05T23:17:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-03T20:47:39.000Z (over 1 year ago)
- Last Synced: 2025-02-27T03:11:21.505Z (11 months ago)
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 96
- Watchers: 4
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsonfile:
Use `jsonfile` to persist a Go value to a JSON file.
```go
type JSONFile
func Load[Data any](path string) (*JSONFile[Data], error)
func New[Data any](path string) (*JSONFile[Data], error)
func (p *JSONFile[Data]) Read(fn func(data *Data))
func (p *JSONFile[Data]) Write(fn func(*Data) error) error
```
There is a bit more thought put into the few lines of code in this repository than you might expect.
If you want more details, see
[the blog post](https://crawshaw.io/blog/jsonfile).