https://github.com/entrlcom/go-json-decoder
JSON Decoder
https://github.com/entrlcom/go-json-decoder
go http-request json pkg request-body security
Last synced: 7 months ago
JSON representation
JSON Decoder
- Host: GitHub
- URL: https://github.com/entrlcom/go-json-decoder
- Owner: entrlcom
- License: mit
- Created: 2024-06-11T19:59:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-05T16:57:20.000Z (9 months ago)
- Last Synced: 2025-06-17T10:57:25.632Z (7 months ago)
- Topics: go, http-request, json, pkg, request-body, security
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON Decoder
## Table of Content
- [Authors](#authors)
- [Examples](#examples)
## Authors
| Name | GitHub |
|--------------|----------------------------------------------------|
| Klim Sidorov | [@entrlcom-klim](https://github.com/entrlcom-klim) |
## Examples
```go
package main
import (
"net/http"
"time"
"flida.dev/unit"
"flida.dev/json-decoder"
)
const limit = unit.B * 128 // 128 B.
type HTTPRequestBody struct {
DateOfBirth time.Time `json:"date_of_birth"`
Name string `json:"name"`
}
func ServeHTTP(w http.ResponseWriter, r *http.Request) {
var body HTTPRequestBody
if err := json_decoder.NewHTTPRequestDecoder(limit).Decode(w, r, &body); err != nil {
// TODO: ...
return
}
// ...
}
```