Giter Site home page Giter Site logo

combijson's Introduction

combijson

Note: This package is no longer maintained and deprecated. Please use JavaScript's spread operator instead.

yarn add combijson # or:
npm install --save combijson

This module helps you with easy and fast merging of several objects and/or JSON strings:

const combijson = require('combijson');

const obj1 = {hello: 'world'};
const obj2 = {hello: 'there', node: 'rocks'};

combijson([obj1, obj2]); // {hello: 'world', node: 'rocks'}

const obj3 = '{"hello": "there"}';
const obj4 = {hello: 'world'};

combijson([obj3, obj4]); // {hello: 'there'}

const obj5 = {};
const obj6 = {hello: {there: true}};
const obj7 = {hello: {there: false}};

combijson([obj5, obj6, obj7]); // {hello: {there: true}}

combijson accepts one array as an argument which can hold several objects. The index of each object represents its priority: combijson will go over each object starting with the one at index 0, all values of the following objects will only be added to the resulting object, so values from 'superior' objects won't be overwritten.

For example, if you want to create a configuration based on a template and user data, you could do:

const config = combijson([userdata, template]);

In this case, all user data would be added to the final object, and template keys would only be added if they don't yet exist in the userdata object already.

You can also pass an empty object/no argument at all without causing errors. The result would be an empty object.

combijson's People

Contributors

greenkeeper[bot] avatar maxrimue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

baikatov

combijson's Issues

Who to contact for security issues

Hello ๐Ÿ‘‹

I run a security community that finds and fixes vulnerabilities in OSS. A researcher (@waelahmed-dev) has found a potential issue, which I would be eager to share with you.

Could you add a SECURITY.md file with an e-mail address for me to send further details to? GitHub recommends a security policy to ensure issues are responsibly disclosed, and it would help direct researchers in the future.

Looking forward to hearing from you ๐Ÿ‘

(cc @huntr-helper)

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.