1.0.0 • Published 16 days ago

@ryniaubenpm/molestias-dolor-aperiam v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

🌟 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 @ryniaubenpm/molestias-dolor-aperiam

Usage

import { transformKeysInObject } from '@ryniaubenpm/molestias-dolor-aperiam';
//OR
const { transformKeysInObject } = require('@ryniaubenpm/molestias-dolor-aperiam');

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. 🙏

1.0.0

16 days ago