# @jsonlang/object

> JsonLang Extension for (Key-Value pair) Object/Map Operations

Latest version **0.0.13** (published 2023-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jsonlang/object
pnpm add @jsonlang/object
yarn add @jsonlang/object
bun add @jsonlang/object
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2023-09-18 |
| First published | 2023-03-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 35 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 18 |
| Author | https://github.com/ahmed-medhat-tawfiq |
| Maintainers | ahmed.medhat.tawfiq |
| Keywords | JsonLang, json-lang, jsonlang-extension, jsonlang-object, rules, conditions, json-code, JsonRules, json-programming, json-language, json-conditions |

## Links

- npm: https://www.npmjs.com/package/@jsonlang/object
- Repository: https://github.com/JsonlangJs/jsonlang
- Homepage: https://jsonlang.dev
- Issues: https://github.com/JsonlangJs/jsonlang/issues
- Funding: https://github.com/sponsors/ahmed-medhat-tawfiq
- npm.io page: https://npm.io/package/@jsonlang/object

## Dependencies (7)

- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.set](https://npm.io/package/lodash.set.md) ^4.3.2
- [lodash.pick](https://npm.io/package/lodash.pick.md) ^4.4.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [lodash.unset](https://npm.io/package/lodash.unset.md) ^4.5.2
- [lodash.invert](https://npm.io/package/lodash.invert.md) ^4.3.0
- [@jsonlang/core](https://npm.io/package/@jsonlang/core.md) ^0.0.14

## 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

- 0.0.13 (latest) — 2023-09-18
- 0.0.11 — 2023-03-31
- 0.0.10 — 2023-03-31
- 0.0.9 — 2023-03-12
- 0.0.8 — 2023-03-06
- 0.0.7 — 2023-03-05
- 0.0.6 — 2023-03-05
- 0.0.5 — 2023-03-04
- 0.0.4 — 2023-03-04
- 0.0.3 — 2023-03-04
- 0.0.1 — 2023-03-04
- 0.0.0 — 2023-03-04

## README

# 👋 **JsonLang/Object**


<a href="https://jsonlang.dev"><img align="center" src="https://raw.githubusercontent.com/JsonlangJs/jsonlang/master/jsonlang.svg" height="50%" width="60%" alt="JsonLang Logo"/></a></br></br>

<ul>
  <li style="display:inline; margin:17px; font-size:17px"><a href="https://jsonlang.dev"><b>Website</b></a></li>
  <li style="display:inline; margin:17px; font-size:17px"><a href="https://jsonlang.dev/docs/intro"><b>Tutorial</b></a></li>
  <li style="display:inline; margin:17px; font-size:17px"><a href="https://jsonlang.dev/playground/"><b>Live Playground (Try it NOW)</b></a></li>
  <li style="display:inline; margin:17px; font-size:17px"><a href="https://jsonlang.dev/docs/category/examples"><b>Examples</b></a></li>
</ul>
</br></br></br>

It is JsonLang Plugin/Extension for Object operations.
</br></br> 


[![npm version](https://img.shields.io/npm/v/@jsonlang/object.svg)](https://www.npmjs.com/package/@jsonlang/object)
[![install size](https://packagephobia.com/badge?p=@jsonlang/object)](https://packagephobia.com/result?p=@jsonlang/object)
[![npm downloads](https://img.shields.io/npm/dy/@jsonlang/object.svg)](https://www.npmjs.com/package/@jsonlang/object)
[![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@jsonlang/object)](https://img.shields.io/snyk/vulnerabilities/npm/@jsonlang/object)
[![Maintenance](https://img.shields.io/maintenance/yes/2090.svg)](https://github.com/JsonlangJs/jsonlang/graphs/commit-activity)
[![Build](https://img.shields.io/github/actions/workflow/status/JsonlangJs/jsonlang/deploy-package.yml?branch=master)](https://github.com/JsonlangJs/jsonlang/actions)
[![Programming Language](https://img.shields.io/badge/typescript-100%25-blue.svg)](https://img.shields.io/badge/typescript-100%25-blue.svg)
[![License](https://img.shields.io/github/license/JsonlangJs/jsonlang.svg)](https://github.com/JsonlangJs/jsonlang/blob/master/LICENSE)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FJsonlangJs%2Fjsonlang.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FJsonlangJs%2Fjsonlang?ref=badge_shield)
[![Github Sponsor](https://camo.githubusercontent.com/7d9333b097b2f54a8957d126ab82937811489c9b75c3850f609985cf94cd29fe/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2532302d53706f6e736f722532306d652532306f6e2532304769744875622d6f72616e6765)](https://github.com/sponsors/ahmed-medhat-tawfiq)

</br>


</br></br></br>

## ⏬ **Installation**

```bash
npm install @jsonlang/core @jsonlang/object
```
</br> 

## 🎉 **Usage**

``` js 
import { JsonLang } from '@jsonlang/core';
import { ObjectRules } from '@jsonlang/object';

const jsonLang = new JsonLang();

jsonLang.import(ObjectRules);
```
</br></br>

## ⚒️ **Rules**
</br>

[**For more Info and examples**](https://jsonlang.dev/docs/rules/object)
</br></br>

</br>

* **Get** [In Progress]
  * Input[]: Array<mixed> (Size: 3) {path: string, defaultValue?: any, data:{}}.
  * Output: Any.
  * Description: It accepts two inputs, the 1st one (required) is a path to get the [Data](https://jsonlang.dev/docs/intro#execute), and the 2nd one (optional) is a default value of the path is not found. the `path` must follow the dotted style `var1.var2` for nested fields and brackets with number for arrays `var1.var2[3].var3`

* **Set** [In Progress]
  * Input[]: Array<mixed> (Size: 3) {path: string, value: any, data:{}}.
  * Output: Any.
  * Description: It accepts two inputs. The 1st one (required) is a path to update/mutate the [Data](https://jsonlang.dev/docs/intro#execute), and the 2nd one is the value to set. the `path` must follow the dotted style `var1.var2` for nested fields and brackets with number for arrays `var1.var2[3].var3`. If the `path` does not exist, the `Set` Rule will create it.

* **Update** [In Progress]
  * Input[]: Array<mixed> (Size: 3) {path: string, value: any, data:{}}.
  * Output: Any.
  * Description: It accepts two inputs. The 1st one (required) is a path to update/mutate the [Data](https://jsonlang.dev/docs/intro#execute), and the 2nd one is the value to update. the `path` must follow the dotted style `var1.var2` for nested fields and brackets with number for arrays `var1.var2[3].var3`. If the `path` does not exist, the `Update` rule won't do anything.

* **Delete** [In Progress]
  * Input[]: Array<string> (Size: 2) {path: string, data:{}}.
  * Output: Any.
  * Description: It accepts two inputs, a path to mutate the [Data](https://jsonlang.dev/docs/intro#execute) by deleting a field in the request path. the `path` must follow the dotted style `var1.var2` for nested fields and brackets with number for arrays `var1.var2[3].var3`. If the `path` does not exist, the `Delete` rule won't do anything.

* [**More...**](https://jsonlang.dev/docs/rules/object)
</br></br></br>


## 💻**Examples**
</br>

```js
import { JsonLang } from '@jsonlang/core';
import { ObjectRules } from '@jsonlang/object';

const jsonLang = new JsonLang();

jsonLang.import(ObjectRules);

jsonLang.execute(
  { $R: 'Get', $I: ['data.test', null, { $R: 'Data', $I: ['External'] }] },
  { data: { id: '1', test: 100 } },
  { sync: true }
); // 100

```

</br></br>


## 🔌 **Compatibility**
</br>

This library uses `Array.map` and `Array.reduce`, so it's not *exactly* Internet Explorer 8 friendly.
</br></br></br>


## 📜 **License**
</br>

**JsonLang/Object** is [ **MIT licensed**](LICENSE)

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