https://github.com/junbong/strict-json-parser
JSON parser for GO language with strict type config.
https://github.com/junbong/strict-json-parser
golang json parser strict type
Last synced: 20 days ago
JSON representation
JSON parser for GO language with strict type config.
- Host: GitHub
- URL: https://github.com/junbong/strict-json-parser
- Owner: junbong
- Created: 2017-06-08T06:41:44.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-09T08:05:24.000Z (almost 9 years ago)
- Last Synced: 2025-01-24T05:31:50.339Z (over 1 year ago)
- Topics: golang, json, parser, strict, type
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Strict JSON Parser
Example:
```go
json := `
{
"name": "Lloyd",
"age": 30,
"height": 184.53,
"weight": 86.5423,
"score": -47,
"graduated": "true",
"hobby": "Listening Music",
"languages": [ "KR", "EN", "JP", "CN" ]
}
`
// Type configs
config := `
{
"name": "text",
"age": "uint",
"height": "float",
"weight": "float32",
"score": "int",
"graduated": "bool"
}
`
p := sparser.New([]byte(config))
// Parser parses given JSON string to map[string]interface{}
res, err := p.Unmarshal([]byte(json))
for k, v := range res {
fmt.Println(k, v, reflect.TypeOf(v).String())
}
```
Result:
```
weight 86.5423 float32
score -47 int
graduated true bool
hobby Listening Music string
languages [KR EN JP CN] []interface {}
name Lloyd string
age 30 uint
height 184.53 float32
```