Skip to content

dimiro1/gojsonexplode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gojsonexplode

What is gojsonexplode?

gojsonexplode go library to flatten/explode nested JSON.

How does it work?

import (
    "fmt"

    "github.com/nytlabs/gojsonexplode"
)
func main() {
    input := `{"person":{"name":"Joe", "address":{"street":"123 Main St."}}}`
    out, err := gojsonexplode.Explodejsonstr(input, ".")
    if err != nil {
        // handle error
    }   
    fmt.println(out))
}

should print:

{"person.address.street":"123 Main St.","person.name":"Joe"}

How are JSON arrays handled?

JSON arrays are flattned using the parent attribute concatenated with a delimiter and the respective index for each of the elements in the array

{"list":[true, false]}

gets exploded to:

{"list.0": true, "list.1":false}

About

a go library to flatten nested JSON

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%