Skip to content

terraindata/deep-objectify

Repository files navigation

deep-objectify

Build Status version dependencies devDependencies

Curly brackets all the way down

This is a tiny JS utility that converts deeply nested structures, which may include layers of objects and arrays, to pure nested objects. The key feature is converting arrays to objects. While objects and arrays are more or less equivalent in JS, it may be easier to reason about complicated data processing and storage if you can guaranteee that your complex JSON object has values that are stricly primitives or child JSON objects.

TypeScript definitions included!

Installation

npm install deep-objectify

Usage

var objectify = require('deep-objectify');

objectify({foo: 'bar', x: ['a', 'b']}); // -> {foo: 'bar', x: {'0': 'a', '1': 'b'}}

See also deepObjectifyTests.ts.