Manage complex object keys in depth.
bun add json-object-keys
pnpm add json-object-keys
npm install json-object-keys
yarn add json-object-keys
import { remove } from 'json-object-keys'
remove(
{
id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'John Doe',
category: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
email: '[email protected]',
age: 29,
...
},
'category'
)
Output
{
id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'John Doe',
- category: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
email: '[email protected]',
age: 29
}
import { remove } from 'json-object-keys'
remove(
{
id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'John Doe',
category: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
email: '[email protected]',
age: 29
},
['category', 'email']
)
Output
{
id: 'e059d01a-7082-4b63-9c70-997491cdcf7c',
name: 'John Doe',
- category: '65bf5579-710d-4f56-9907-8c0bb1b2f0d2',
- email: '[email protected]',
age: 29
}
import { replace } from 'json-object-keys'
replace({ id: 1, foo: 2, baz: 3 }, { foo: 'bar' })
Output
{
id: 1,
+ bar: 2,
baz: 3
}
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
{
+ 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'
}
]
}
This project is licensed under the MIT License.