@tibinsunny/arraytojson

1.0.0 • Public • Published

ArraytoJson

A better way to convert Array to JSON.

Install

npm install arraytojson

Usage

const arraytojson = require("arraytojson");

let testArray = [1,2,3];
arraytojson.toJson(testArray);
// => { element0: 1, element1: 2, element2: 3 }

let rules =["first","second","third"];
arraytojson.toJsonStrict(testArray,rules)

// => { first: 1, second: 2, third: 3 }

API

toJson(array)

Converts the given array to json with default keys(element1,element2,element3 etc...).

toJsonStrict(array,rules)

Converts the array to json based on the rules. Rules are basically keys to the json.

Package Sidebar

Install

npm i @tibinsunny/arraytojson

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.03 kB

Total Files

3

Last publish

Collaborators

  • tibinsunny