Skip to content
/ GoJSON Public

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

Notifications You must be signed in to change notification settings

1swaraj/GoJSON

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"
            }
         }
      }
   }
}`))
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

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

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages