https://github.com/1swaraj/gojson
Parsing JSON is a hassle in golang. This package will allow you to parse and search elements in a json without structs.
https://github.com/1swaraj/gojson
go gojson gojsons golang json json-parser parse struct
Last synced: 9 months ago
JSON representation
Parsing JSON is a hassle in golang. This package will allow you to parse and search elements in a json without structs.
- Host: GitHub
- URL: https://github.com/1swaraj/gojson
- Owner: 1swaraj
- Created: 2020-12-19T09:59:08.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-07T19:29:06.000Z (over 4 years ago)
- Last Synced: 2025-03-30T10:05:17.269Z (10 months ago)
- Topics: go, gojson, gojsons, golang, json, json-parser, parse, struct
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 24
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# GoJSON
Parsing JSON is a hassle in golang. This package will allow you to parse and search elements in a json without structs.
## Install gojson
go get github.com/swaraj1802/GoJSON/gojson
## Usage
Import
```go
import "github.com/swaraj1802/GoJSON/gojson"
```
Sample Code
```go
jsonParsed, err := gojson.ParseJSON([]byte(`{
"glossary":{
"title":"example glossary",
"GlossDiv":{
"title":"S",
"GlossList":{
"GlossEntry":{
"ID":"SGML",
"SortAs":"SGML",
"GlossTerm":"Standard Generalized Markup Language",
"Acronym":"SGML",
"Abbrev":"ISO 8879:1986",
"GlossDef":{
"para":"A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso":[
"GML",
"XML"
]
},
"GlossSee":"markup"
}
}
}
}
}`))
if err != nil {
panic(err)
}
value, ok := jsonParsed.Search("glossary", "GlossDiv", "title")
if ok != nil {
panic(errors.New("Element doesn't exist"))
}
output := value.JSONData()
fmt.Println(output)
```
Github Actions Enabled