Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

92 Commits

Repository files navigation

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

import"github.com/swaraj1802/GoJSON/gojson"

Sample Code

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" } } } }}`))
iferr!=nil {
panic(err)
}
value, ok:=jsonParsed.Search("glossary", "GlossDiv", "title")
ifok!=nil {
panic(errors.New("Element doesn't exist"))
}
output:=value.JSONData()
fmt.Println(output)

Github Actions Enabled

About

Parsing JSON is a hassle in golang. This package will allow you to parse and search elements in a json without structs.

Topics

Resources

Stars

24 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages