https://github.com/sunaipa5/jager
Library for quickly generate JSON and send it via http.responseWriter
https://github.com/sunaipa5/jager
go golang json library
Last synced: 3 months ago
JSON representation
Library for quickly generate JSON and send it via http.responseWriter
- Host: GitHub
- URL: https://github.com/sunaipa5/jager
- Owner: sunaipa5
- License: mit
- Created: 2024-06-13T20:15:24.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-13T21:27:16.000Z (about 2 years ago)
- Last Synced: 2025-08-15T00:40:53.289Z (11 months ago)
- Topics: go, golang, json, library
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jager
This library was created to generate `JSON` in various and fast ways and send it via `http.responseWrite.`
[](https://pkg.go.dev/github.com/sunaipa5/jager)
## Examples
### String To JSON
```go
package main
import (
"net/http"
"github.com/sunaipa5/jager"
)
func main(){
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
jager.String(w, `{"type":"jager string","name":"john","surname":"doe","age":30, "isStudent":true}`)
})
http.ListenAndServe(":3000", nil)
}
```
### Map To JSON
```go
package main
import (
"net/http"
"github.com/sunaipa5/jager"
)
func main(){
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
jager.Map(w, map[string]interface{}{
"name": "John",
"surname": "Doe",
"age": 30,
"isStudent": true,
})
})
http.ListenAndServe(":3000", nil)
}
```
### Struct To JSON
```go
package main
import (
"net/http"
"github.com/sunaipa5/jager"
)
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
Email string `json:"email"`
}
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
person := Person{
Name: "John Doe",
Age: 30,
Email: "johndoe@example.com",
}
jager.Struct(w,person)
})
http.ListenAndServe(":3000", nil)
}
```