Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crufter/nested
This Go package makes it easier to handle nested JSON documents.
https://github.com/crufter/nested
Last synced: 2 months ago
JSON representation
This Go package makes it easier to handle nested JSON documents.
- Host: GitHub
- URL: https://github.com/crufter/nested
- Owner: crufter
- Created: 2012-05-25T07:18:40.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2021-09-03T14:56:15.000Z (over 3 years ago)
- Last Synced: 2024-06-19T02:00:07.832Z (6 months ago)
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
nested
=====The Nested Go package makes it easier to handle (too) big nested JSON structures.
How to use
=============
Lets say you have the next JSON:
```
j := `{
"hello": {
"this": {
"is": {
"an": {
"example": "hi"
}
}
}
}
}`
```Now if you unmarshal it to u (pseudocode)
```
u := unmarshal(j)
```You will have a hard time accessing members in u, like
```
u.(map[string]interface{})["hello"].(map[string]interface{})["this"].(map[string]interface{}) //... etc etc
```But not with package Nested!
```
magic, ok := nested.Get(u, "hello.this.is.an.example")
fmt.Println(magic, ok)
```Will output something like:
```
"hi" true
```It's magic, really!