Newton's Principia Mathematica
Miss any of our Open RFC calls?Watch the recordings here! »

stringify-object-keys

1.4.0 • Public • Published

Stringify Object Keys npm

Get stringified keys from an object or array.

Recieves an object or array and returns an array with all keys/indices stringified.

Key strings are formatted in syntax compatible with popular framework methods, such as lodash.get, even supports keys with dots in their names!

Install

npm install --save stringify-object-keys

Usage

const stringify = require("stringify-object-keys");
 
const family = {
  lastname: "Bluth",
  members: [
    {
      firstname: "Nichael",
      nicknames: []
    },
    {
      "first.name": "George",
      nicknames: ["GOB", "Getaway"]
    }
  ]
};
 
console.log(stringify(family));
 
/*
  [
    'lastname',
    'members[0].firstname',
    'members[0].nicknames',
    'members[1][\'first.name\']',
    'members[1].nicknames[0]'
    'members[1].nicknames[1]'
  ]
*/

Changelog

See documentation.

License

MIT

Install

npm i stringify-object-keys

DownloadsWeekly Downloads

53

Version

1.4.0

License

MIT

Unpacked Size

5.18 kB

Total Files

6

Last publish

Collaborators

  • avatar