flatten

package module
v0.9.8-97a24c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2020 License: MIT Imports: 3 Imported by: 0

README

go-flatten

Really simple library and demo app to flatten JSON into dot notation. Forked from Nick Glynn

GoDoc GoCard Build

Getting Started

Simple stuff - use go get and it will also install the flatten demo app.

go get -u github.com/cameronnewman/go-flatten/...
$ flatten -s simple.json -w foo.txt
$ flatten -s simple.json
sample.someitem.thesearecool.1.eggs false
sample.someitem.thesearecool.1.neat tubular
sample.someitem.thesearecool.0.neat wow
sample.someitem.thesearecool.1.sausage true

You can use the library as you see fit. Not sure how useful it will be tho :D

Issues

  • None

License

MIT Licensed

Documentation

Overview

Package flatten is a simple library to flatten JSON into dot notation. Forked from https://github.com/17twenty/flatter

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map map[string]string

Map is our datatype we use to extend the base types and allow easier flattening

func Flatten

func Flatten(thing map[string]interface{}) Map

Flatten takes a structure and turns into a flat map[string]string.

Within the "thing" parameter, only primitive values are allowed (slices, maps, primitives, and any combination of those together)

func (Map) Contains

func (m Map) Contains(key string) bool

Contains returns true if the map contains the given key.

func (Map) Delete

func (m Map) Delete(prefix string)

Delete deletes a key out of the map with the given prefix.

func (Map) Keys

func (m Map) Keys() []string

Keys returns all of the top-level keys in this map

func (Map) Merge

func (m Map) Merge(m2 Map)

Merge merges the contents of the other Map into this one.

This merge is smarter than a simple map iteration because it will fully replace arrays and other complex structures that are present in this map with the other map's. For example, if this map has a 3 element "foo" list, and m2 has a 2 element "foo" list, then the result will be that m has a 2 element "foo" list.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL