1.0.6 • Published 7 years ago

changejson v1.0.6

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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' ] }
1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago