Code Monkey home page Code Monkey logo

changejson's Introduction

changejson

npm license github-issues

Function's to manipulate JSON for easy access.

NPM

Features

  • Change the schema of the Json
  • Compare and count's the keys
  • Merge the same keys

Change the schema of the Json

  • This function will input the object, schema. returned object will be in the schema that is specified.
  • Input:
    console.log(JSON.stringify(changeJson.changeSchema(
       {
           'x': 1,
           'y': 2
       },
       ['y','x']
       ),null,' ')
    
  • Output:
    {
      'y': 2,
      'x': 1
    }
    

Compare and count's the keys

  • This function compares two objects are returns the intersection of keys
  • Input:
    console.log(cj.compareAndCount({'x':1},{'x':2,'y':2}))
    
  • Output:
    { compare: [ 'x' ], count: 1 }
    

Merge the same keys

  • You can pass in an array of objects and get out a single object, with all the keys from every object and an array of the values
  • Input:
    console.log(merge([
         {"first_name":"Frank", "last_name":"Billy", "friends":["Pam", "Susy"]},
         {"first_name":"Sally", "last_name":"Doe", "middle_name":"Krissy", "friends":["Rick", "Walter"]},
         {"first_name":"Don"}
     ]))
    
  • Output:
    { first_name: [ 'Frank', 'Sally', 'Don' ],
       last_name: [ 'Billy', 'Doe' ],
       friends: [ 'Pam', 'Susy', 'Rick', 'Walter' ],
       middle_name: [ 'Krissy' ] }
    

changejson's People

Contributors

devalltime avatar schu34 avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

ssk0001

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.