# jsondo

> JSON object management utility

Latest version **2.0.4** (published 2018-07-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install jsondo
pnpm add jsondo
yarn add jsondo
bun add jsondo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2018-07-11 |
| First published | 2018-05-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 19.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Justin Mathews |
| Maintainers | jmathews-shiver |
| Keywords | JSON, jsondo, json build |

## Links

- npm: https://www.npmjs.com/package/jsondo
- npm.io page: https://npm.io/package/jsondo

## Dependencies (1)

- [objcheck](https://npm.io/package/objcheck.md) ^1.0.7

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.4 (latest) — 2018-07-11
- 2.0.3 — 2018-05-18
- 2.0.1 — 2018-05-17
- 2.0.0 — 2018-05-16
- 1.2.1 — 2018-05-15
- 1.1.1 — 2018-05-10

## README

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [JSONDo][1]
-   [getValue][2]
-   [buildBranch][3]
-   [mergeDeep][4]
-   [crawlForward][5]
-   [crawlReverse][6]

## JSONDo

Prodives a JSON configuration module that allows simply creation and lookup functionality
through dot notation

**Meta**

-   **version**: 2.0.0
-   **author**: Justin Mathews

## getValue

parses source object and retrieves value if exists

**Parameters**

-   `sourceJSON` **[JSON][7]** JSON object containing value
-   `keyMap` **[string][8]** Dot '.' delimited string mapping location of value in the source object

Returns **any** 

**Meta**

-   **author**: Justin Mathews

## buildBranch

Creates JSON and assigns value

**Parameters**

-   `keyMap` **[String][8]** Dot '.' delimited string that maps the JSON hierarchy to by created
-   `value` **any** Object assigned to the final JSON element

**Examples**

```javascript
buildBranch('this.is.a.nested.value', 'example') => {this:{is:{a:{nested:{value: 'example'}}}}}
```

Returns **[JSON][7]** Single JSON branch

**Meta**

-   **author**: Justin Mathews

## mergeDeep

Merges multilevel JSON object to return a combined result.

**Parameters**

-   `parentJSON` **[JSON][7]** 
-   `newJSON` **[JSON][7]** 

**Examples**

```javascript
A simple merge tha will add an element to a nested JSON object and overwrite another where already exists
let source = {a:1, b:{c: 'not bob', d:{age: 42}}}
let newJson = {b:{c:'is bob', d:{sex:'male'}}}
mergeDeep(source, newJson) => {a:1, b:{c:'is bob', d:{age:42, sex:'male'}}}
```

Returns **[JSON][7]** Merged Objects

**Meta**

-   **author**: Justin Mathews

## crawlForward

Process crawls the JSON starting from the beginning moving to the end. The callback is executed at each layer

**Parameters**

-   `config` **[JSON][7]** Object meeting TYPE configType structure
-   `cb` **[Function][9]** Anon function that will be executed for each layer of the JSON processed. Requires a single parameter to allow the current JSON layer to be passed. A "return" is niether required nor desired
-   `subLevelName` **[String][8]** Name of element that leads to the next layer.
-   `level` **[Number][10]** (undefined) Value sets the starting position of the hierarchy. 
    This is primarily used by the process to pass the previous layer depth.  Adds elemeent "level"
    If undefined, the hierarchy is not mapped

Returns **[JSON][7]** 

## crawlReverse

Process crawls the JSON starting from the end of each branch moving to the beginning. The callback is executed at each layer

**Parameters**

-   `json` **[JSON][7]** Object meeting TYPE configType structure
-   `cb` **[Function][9]** Anon function that will be executed for each layer of the JSON processed. Requires a single parameter to allow the current JSON layer to be passed. A "return" is niether required nor desired
-   `subLevelName` **[String][8]** Name of element that leads to the next layer.

Returns **[JSON][7]** JSON object with the desired changes

[1]: #jsondo

[2]: #getvalue

[3]: #buildbranch

[4]: #mergedeep

[5]: #crawlforward

[6]: #crawlreverse

[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON

[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

---
_Source: https://npm.io/package/jsondo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
