https://github.com/terraindata/deep-objectify
Curly brackets all the way down
https://github.com/terraindata/deep-objectify
arrays deep javascript nested object objectify typescript
Last synced: 8 months ago
JSON representation
Curly brackets all the way down
- Host: GitHub
- URL: https://github.com/terraindata/deep-objectify
- Owner: terraindata
- License: other
- Created: 2018-12-24T21:19:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:15:07.000Z (almost 3 years ago)
- Last Synced: 2025-04-14T02:17:35.375Z (9 months ago)
- Topics: arrays, deep, javascript, nested, object, objectify, typescript
- Language: TypeScript
- Homepage:
- Size: 942 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deep-objectify
[](https://travis-ci.org/terraindata/deep-objectify)
[](https://www.npmjs.org/package/deep-objectify)
[](https://david-dm.org/terraindata/deep-objectify)
[](https://david-dm.org/terraindata/deep-objectify#info=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
```js
var objectify = require('deep-objectify');
objectify({foo: 'bar', x: ['a', 'b']}); // -> {foo: 'bar', x: {'0': 'a', '1': 'b'}}
```
See also [deepObjectifyTests.ts](https://github.com/terraindata/deep-objectify/blob/master/deepObjectifyTests.ts).