Giter Site home page Giter Site logo

flat's People

Contributors

leslie-qiwa avatar nqd avatar nqd-cb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flat's Issues

[feature request] flatten/unflatten to/from `map[string]string` with safe on

Hello,

I am looking for a pkg that allows flattening a nested struct to map[string]string so I can save it to a string based text file or KV store.

I find this pkg is almost there, except that when the value is an array or slice, extra handling is needed for my case.

Please consider adding such support. Thanks!

`mergo.Merge` skips maps with nil values in it

When merging maps with nil values current version of mergo skips them

nested := make(map[string]interface{})

e := mergo.Merge(&nested, map[string]interface{}{"x": nil})

if e == nil {
    fmt.Println(nested)
}
map[]

New version of mergo allows us to change that behavior and avoid losing key-value pairs

nested := make(map[string]interface{})

e := mergo.Merge(&nested, map[string]interface{}{"x": nil}, func(c *mergo.Config) {c.Overwrite = true})

if e == nil {
    fmt.Println(nested)
}
map[x:<nil>]

unflattening flat arrays leads to wrong result

When unflattening something like

map[string]interface{}{
	"pew.0": "woop",
}

The result is

map[pew:map[0:woop]]

or as a type map[string]map[string]interface{}

What I would expect is to be the result is

map[pew:[woop]]

or as a type map[string][]interface{}

Are there any plans to remedy this? Would you be willing to merge such a feature if I (or someone else) implemented it?

PS: I'm working on recursively unflattening input - I will upstream that in a PR here later :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.