obj2arr
convert object to array
Installation
npm install obj2arr
Usage
setup
var obj2arr = ; var defs = case1: type: 'array' items: id: 'key' type: 'string' id: 'num' type: 'number' ;obj2arr;
encode
var data = key: 'test1' num: 10;var encoded = obj2arr;console;// -- output --// [ 'test1', 10 ]
decode
var decoded = obj2arr;console;// -- output --// { key: 'test1', num: 10 }
Tools
toArrSchema
var objSchema = type: 'object' properties: key: id: 'key' type: 'string' num: id: 'num' type: 'number' ;var arrSchema = obj2arrtools;console;// -- output --// { type: 'array',// items: [ { id: 'key', type: 'string' }, { id: 'num', type: 'number' } ] }
toObjSchema
var arrSchema = type: 'array' items: id: 'key' type: 'string' id: 'num' type: 'number' ;var objSchema = obj2arrtools;console;// -- output --// { type: 'object',// properties:// { key: { id: 'key', type: 'string' },// num: { id: 'num', type: 'number' } } }
Contribution
- Fork it ( https://github.com/iyu/obj2arr/fork )
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
npm test
command and confirm that it passes - Create new Pull Request