https://github.com/leberkleber/go-additional-json
https://github.com/leberkleber/go-additional-json
golang golang-library golang-tool json json-parser
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/leberkleber/go-additional-json
- Owner: leberKleber
- License: apache-2.0
- Created: 2020-02-09T21:40:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-25T15:39:18.000Z (over 6 years ago)
- Last Synced: 2024-12-29T15:46:50.301Z (over 1 year ago)
- Topics: golang, golang-library, golang-tool, json, json-parser
- Language: Go
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-additional-json
## Example
```go
package main
import (
"fmt"
"github.com/leberKleber/go-additional-json"
"os"
)
func main() {
s := struct {
ID int `json:"id"`
Name string `json:"name"`
Description struct {
Short string `json:"short"`
Long string `json:"long"`
} `json:"description"`
Other map[string]string `json:"-" aj:"other"`
}{}
j := `{
"id": 54321,
"name": "NaMe",
"description": {
"short": "short",
"long": "lloonngg"
},
"other1": "ootthheerr11",
"other2": "ootthheerr22"
}`
err := additionaljson.DefaultUnmarshaler.Unmarshal([]byte(j), &s)
if err != nil {
fmt.Printf("a error ocurred: %s", err)
os.Exit(1)
}
fmt.Printf("unmarshaled:\n%v", s)
}
```
Output:
```text
unmarshaled:
{54321 NaMe {short lloonngg} map[other1:ootthheerr11 other2:ootthheerr22]}
```