2.0.0 • Published 3 years ago

object-dot-parser v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Object Dot Parser

This module allows you to parse objects whose attributes are strings with points, and converts them into nested objects.

npm version MIT License NodeJS install size npm downloads

Compatibility

The minimum supported version of Node.js is v10.

Usage

Installation

$ npm i object-dot-parser

Test

Run from the root folder:

$ npm run test

Importing

const objectDotParser = require('object-dot-parser');

Example

const objectDotParser = require('object-dot-parser');

const person = {
  'person.name': 'Luis',
  'person.age': 74,
  'person.address.city': 'Atlanta',
  'person.address.street.name': 'St. Joseph',
  'person.address.street.number': '#34-46',
  'person.position': 'Software Engineer',
  'social.instagram': 'luisfuentech',
  'social.twitter': 'luisfuentech',
  'social.github': 'luisfuentech',
};

console.log(JSON.stringify(objectDotParser(person), null, 2));

Output

{
  "person": {
    "name": "Luis",
    "age": 74,
    "address": {
      "city": "Atlanta",
      "street": {
        "name": "St. Joseph",
        "number": "#34-46"
      }
    },
    "position": "Software Engineer"
  },
  "social": {
    "instagram": "luisfuentech",
    "twitter": "luisfuentech",
    "github": "luisfuentech"
  }
}

License

MIT

2.0.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago