Giter Site home page Giter Site logo

flattie's People

Contributors

lukeed avatar tripodsgames 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  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  avatar  avatar

flattie's Issues

Keep empty arrays and objects

Saw your new version last week and had to check if it could replace the one I've written. Among the test cases I've used is the Reddit JSON output, i.e.: https://www.reddit.com/r/cute.json

The one thing missing in flattie is keeping empty arrays or objects. I very much depend on the output to be reversible (unflatten(flatten(input)) deep equal to input), so I can't replace my implementation (yet).

Could keepNullish also keep other empty structures or could you change it to keepEmpty = <none, null, all>?

PS: Additional info about why I'm even flattening. I'm using a DB that holds JSON records, but only the first level can be indexed (i.e. no '.' inside the attribute selector). The API on-top does now transparent flattening/unflattening on write&read to make creating indexes easier. But consumers of the API would see the magic if empty structs are dropped.

Possible to keep null values?

Right now I'm using a less-awesome library for merging objects as part of some JSON:API tooling, but specs for JSON:API treat null as a meaningful value (used to specify deleting a property on a sparse update).

I see you're checking for null explicitly if (val == null) I'm wondering if there might be a way to specify keeping null?

โค๏ธ ๐Ÿ™‡

invalid result for nested array

$ npm install --save flat-obj
...
+ [email protected]
$ node
> flatObj = require('flat-obj');
[Function: flatten]
> flatObj({a: null, b: 'c', d: [1,2] })
{ b: 'c', d: [ {}, {} ] }
> flatObj({a: null, b: 'c', d: [1,2], e: { f: ['g', 'h']}})
{ b: 'c', d: [ {}, {} ], e_f: [ { '0': 'g' }, { '0': 'h' } ] }

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.