https://github.com/joaopaulomoraes/json-object-keys
Manage complex object keys in depth.
https://github.com/joaopaulomoraes/json-object-keys
depth json nesting parser regex stringify
Last synced: 7 months ago
JSON representation
Manage complex object keys in depth.
- Host: GitHub
- URL: https://github.com/joaopaulomoraes/json-object-keys
- Owner: joaopaulomoraes
- License: mit
- Created: 2023-02-28T18:59:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-28T22:38:42.000Z (over 1 year ago)
- Last Synced: 2025-02-27T12:17:11.796Z (8 months ago)
- Topics: depth, json, nesting, parser, regex, stringify
- Language: TypeScript
- Homepage:
- Size: 520 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# json-object-keys | ⚠️ WIP ⚠️
Manage complex object keys in depth.
## Table of contents
- [json-object-keys | ⚠️ WIP ⚠️](#json-object-keys--️-wip-️)
- [Table of contents](#table-of-contents)
- [Install](#install)
- [Bun](#bun)
- [PNPM](#pnpm)
- [NPM](#npm)
- [Yarn](#yarn)
- [Remove](#remove)
- [Remove an unique key](#remove-an-unique-key)
- [Remove multiple keys](#remove-multiple-keys)
- [Replace](#replace)
- [Replace an unique key](#replace-an-unique-key)
- [Replace multiple keys](#replace-multiple-keys)
- [License](#license)## Install
### Bun
```sh
bun add json-object-keys
```### PNPM
```sh
pnpm add json-object-keys
```### NPM
```sh
npm install json-object-keys
```### Yarn
```sh
yarn add json-object-keys
```## Remove
### Remove an unique key
```ts
import { remove } from 'json-object-keys'remove(
{
id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'John Doe',
category: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
email: 'john@doe.com',
age: 29,
...
},
'category'
)
```Output
```diff
{
id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'John Doe',
- category: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
email: 'john@doe.com',
age: 29
}
```### Remove multiple keys
```ts
import { remove } from 'json-object-keys'remove(
{
id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'John Doe',
category: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
email: 'john@doe.com',
age: 29
},
['category', 'email']
)
```Output
```diff
{
id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'John Doe',
- category: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
- email: 'john@doe.com',
age: 29
}
```## Replace
### Replace an unique key
```ts
import { replace } from 'json-object-keys'replace({ id: 1, foo: 2, baz: 3 }, { foo: 'bar' })
```Output
```diff
{
id: 1,
+ bar: 2,
baz: 3
}
```### Replace multiple keys
```ts
import { replace } from 'json-object-keys'replace(
{
uuid: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
name: 'Grandchild 1',
children: [
{
uuid: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'Great Grandchild 1'
},
{
uuid: 'c579a0b8-c2c7-44e2-a7d9-2edba8f7b472',
name: 'Great Grandchild 2'
}
]
}, { uuid: 'id', children: 'node' })
```Output
```diff
{
+ id: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
name: 'Grandchild 1',
+ node: [
{
+ id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'Great Grandchild 1'
},
{
+ id: 'c579a0b8-c2c7-44e2-a7d9-2edba8f7b472',
name: 'Great Grandchild 2'
}
]
}
```## License
This project is licensed under the MIT License.