Skip to content

ansteh/shape-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Install

Using npm:

npm install shape-array

Usage

Shape array to a json object:

'use strict';
const shape = require('shape-array');
const personify = shape.scheme(['id', 'name', 'address.street', 'address.zip']);

let data = [1, 'John', 'github', '1234'];
let person = personify(data);
//person equals:
{
  id: 1,
  name: 'John',
  address: {
    street: 'github',
    zip: '1234'
  }
}

Reverse json to array:

const reverse = shape.reverse(['id', 'name', 'address.street', 'address.zip']);

let json = {
  id: 1,
  name: 'John',
  address: {
    street: 'github',
    zip: '1234'
  }
};
let array = reverse(json);
//array equals:
[1, 'John', 'github', '1234']

Related

License

MIT © Andre Stehle

About

convert array to json object

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy