json-disect

1.0.4 • Public • Published

json-disect

An npm module to perform all kinds of operations like key extract, value extract,sorting based on keys/values,etc.

Installations:

npm install json-disect

Funtions

getKeyString(str):

Paramter str is a valid JSON string
returns a string with each key in JSON object separated by a comma

getObjectString(str):

Paramter str is a valid JSON string
returns a string with each value of each key in JSON object separated by a comma

getObjectArray(str):

Paramter str is a valid JSON string
returns an array with each key in JSON object

sortOnKey(data,key,type):

Paramter data is a valid JSON array
Paramter key is the key-name for based on which the elements of the data array is sorted
Parameter type = 0 for sorting in ascending order and type=1 for descending order
returns a sorted (ascending/descending) based on the above parameters

Example

var jsDisect = require('json-disect')
var obj={ name:'sapta', age:23, email:'dey7.kol@gmail.com' } console.log(jsDisect.getKeyString(JSON.stringify(obj))) console.log(jsDisect.getObjectString(JSON.stringify(obj))) console.log(jsDisect.getObjectArray(JSON.stringify(obj))) console.log(jsDisect.sortOnKey(obj,'age'))

Package Sidebar

Install

npm i json-disect

Weekly Downloads

5

Version

1.0.4

License

MIT

Unpacked Size

4.74 kB

Total Files

4

Last publish

Collaborators

  • saptadey