Skip to content

A Go library for dealing with deserialized data for which the structure is dynamic or unknown

License

Notifications You must be signed in to change notification settings

macabot/solenodon

Repository files navigation


Solenodon

A Go library for dealing with deserialized data for which the structure is dynamic or unknown.

GoDoc Build Status Travis Coverage Status Go Report Card GitHub

InstallationHow to useCreditsLicense

Installation

go get github.com/macabot/solenodon

How to use

Solenodon must be used in combination with a serialization library that is able to deserialize data into a tree structure of maps and slices given a target of type interface{}.

Supported:

Unsupported:

Example

The following shows an example of how to use the Has, Get, Delete and SetData method:

raw := []byte(`{"foo":"bar","items":[2,3,{"i":6,"j":7}]}`)
container, err := solenodon.NewContainerFromBytes(raw, json.Unmarshal)
if err != nil {
	panic(err)
}
fmt.Println(container.Has("foo")) // true
fmt.Println(container.Get("foo").Data().(string)) // bar
container.Get("items", 2, "j").SetData(44)
container.Delete("items", 0)
b, err := json.Marshal(container.Data())
if err != nil {
	panic(err)
}
fmt.Println(string(b)) // {"foo":"bar","items":[3,{"i":6,"j":44}]}

You can find more examples here.

Credits

This library was inspired by gabs.

License

Solenodon is made available under the MIT License.

About

A Go library for dealing with deserialized data for which the structure is dynamic or unknown

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages