@diahkomalasarinpm/sequi-corporis-culpa

1.0.0 • Public • Published

🌟 JSON Key Formatter

Description

This package allows you to replace the keys found in a JSON object with the provided values.

Features

  • Replaces keys in an object with the given values.
  • Supports nested objects.
  • Supports array values.

Installation

npm install @diahkomalasarinpm/sequi-corporis-culpa

Usage

import { transformKeysInObject } from '@diahkomalasarinpm/sequi-corporis-culpa';
//OR
const { transformKeysInObject } = require('@diahkomalasarinpm/sequi-corporis-culpa');

const obj = {
  _id: 1,
  name: 'John Doe',
  age: 30,
  address: {
    street: '123 Main Street',
    city: 'Anytown',
    state: 'CA',
    zip: '12345',
  },
};

const keyMappings = {
  _id: 'id',
  name: 'fullName',
  'address.city': 'location',
};

const transformedObj = transformKeysInObject(obj, keyMappings);

console.log(transformedObj);

Output

{
  "id": 1,
  "fullName": "John Doe",
  "age": 30,
  "address": {
    "street": "123 Main Street",
    "location": "Anytown",
    "state": "CA",
    "zip": "12345"
  }
}

Thanks!

Thanks for choosing to use this package! If you have any questions or feedback, please feel free to let me know. 🙏

Readme

Keywords

Package Sidebar

Install

npm i @diahkomalasarinpm/sequi-corporis-culpa

Weekly Downloads

61

Version

1.0.0

License

MIT

Unpacked Size

17.1 kB

Total Files

10

Last publish

Collaborators

  • tul992319