{"name":"dot-object","description":"dot-object makes it possible to transform and read (JSON) objects using dot notation.","version":"1.4.0","author":{"name":"Rob Halff","email":"rob.halff@gmail.com"},"repository":{"type":"git","url":"git://github.com/rhalff/dot-object.git"},"bugs":{"url":"https://github.com/rhalff/dot-object/issues"},"main":"index","bin":{"dot-object":"./bin/dot-object"},"scripts":{"test":"gulp test","watch":"gulp watch","lint":"gulp lint","dist":"gulp dist"},"standard":{"globals":["it","describe","beforeEach"]},"devDependencies":{"gulp":"^3.9.0","gulp-beautify":"^2.0.0","gulp-headerfooter":"^1.0.3","gulp-mocha":"^2.1.3","gulp-rename":"^1.2.2","gulp-standard":"^5.2.2","gulp-uglify":"^1.2.0","gulp-util":"^3.0.6","mocha":"2.x.x","should":"7.x.x","underscore.string":"latest"},"keywords":["json","filter","transform","dot notation","dot"],"dependencies":{"commander":"^2.8.1","glob":"^5.0.14"},"gitHead":"d833417ec11d44a164b70ab2d0183e666b158776","homepage":"https://github.com/rhalff/dot-object#readme","_id":"dot-object@1.4.0","_shasum":"cccb2c7f13019ed2b62a3f90af3ae330dcbbeb29","_from":".","_npmVersion":"3.7.0","_nodeVersion":"5.2.0","_npmUser":{"name":"rhalff","email":"rob.halff@gmail.com"},"dist":{"shasum":"cccb2c7f13019ed2b62a3f90af3ae330dcbbeb29","tarball":"http://registry-npm.ywwl.com/dot-object/download/dot-object-1.4.0.tgz","integrity":"sha512-8aLHjqJbvMqJvehoPLSAqYWcYBsJVH7R6nMbhxyL8/HC/uCdTDi3B64uVuSPWHMMTsfJHfqE96PtrXH9jHa53Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBrCatvaGGP5SQsMMt9U50CHP9iQGeduhHoa1Ge3g2w6AiBkOKXBmo5eOhjEGBjAdl02aWEoZVLV+U9lZlbxuy7g9A=="}],"size":19451,"noattachment":false,"key":"/dot-object/-/dot-object-1.4.0.tgz"},"maintainers":[{"name":"rhalff","email":"rob.halff@gmail.com"}],"_npmOperationalInternal":{"host":"packages-6-west.internal.npmjs.com","tmp":"tmp/dot-object-1.4.0.tgz_1455481174411_0.8865523582790047"},"directories":{},"readme":"[![Build Status](https://travis-ci.org/rhalff/dot-object.png)](https://travis-ci.org/rhalff/dot-object)\n\nDot-Object\n========\n\nDot-Object makes it possible to transform javascript objects using dot notation.\n\n### Installation\n\nInstall from npm:\n```\n  npm install dot-object --save\n```\n\nInstall from bower:\n\n```\n  bower install dot-object --save\n```\n\n### Download\n\n  * Development version: https://unpkg.com/dot-object/dist/dot-object.js *Uncompressed with Comments*\n  * Production version: https://unpkg.com/dot-object/dist/dot-object.min.js *Minified*\n\n## Usage\n\n#### Move a property within one object to another location\n```javascript\nvar dot = require('dot-object');\n\nvar obj = {\n  'first_name': 'John',\n  'last_name': 'Doe'\n};\n\ndot.move('first_name', 'contact.firstname', obj);\ndot.move('last_name', 'contact.lastname', obj);\n\nconsole.log(obj);\n\n{\n  contact: {\n    firstname: 'John',\n    lastname: 'Doe'\n  }\n}\n\n```\n\n#### Copy property from one object to another\n```javascript\nvar dot = require('dot-object');\n\nvar src = {\n  name: 'John',\n  stuff: {\n    phone: {\n      brand: 'iphone',\n      version: 6\n    }\n  }\n};\n\nvar tgt = {name: 'Brandon'};\n\ndot.copy('stuff.phone', 'wanna.haves.phone', src, tgt);\n\nconsole.log(tgt);\n\n{\n  name: 'Brandon',\n  wanna: {\n    haves: {\n      phone: {\n        brand: 'iphone',\n        version: 6\n      }\n    }\n  }\n}\n\n```\n\n#### Transfer property from one object to another\n\nDoes the same as copy but removes the value from the source object:\n\n```javascript\ndot.transfer('stuff.phone', 'wanna.haves.phone', src, tgt);\n\n// src: {\"name\":\"John\",\"stuff\":{}}\n// tgt: {\"name\":\"Brandon\",\"wanna\":{\"haves\":{\"phone\":{\"brand\":\"iphone\",\"version\":6}}}\n```\n\n\n#### Expand to an object\n\n```javascript\nvar dot = require('dot-object');\n\nvar row = {\n  'id': 2,\n  'contact.name.first': 'John',\n  'contact.name.last': 'Doe',\n  'contact.email': 'example@gmail.com',\n  'contact.info.about.me': 'classified',\n  'devices[0]': 'mobile',\n  'devices[1]': 'laptop',\n  'some.other.things.0': 'this',\n  'some.other.things.1': 'that'\n};\n\ndot.object(row);\n\nconsole.log(row);\n\n{\n  \"id\": 2,\n  \"contact\": {\n    \"name\": {\n      \"first\": \"John\",\n      \"last\": \"Doe\"\n    },\n    \"email\": \"example@gmail.com\",\n    \"info\": {\n      \"about\": {\n        \"me\": \"classified\"\n      }\n    }\n  },\n  \"devices\": [\n    \"mobile\",\n    \"laptop\"\n  ],\n  \"some\": {\n    \"other\": {\n      \"things\": [\n        \"this\",\n        \"that\"\n      ]\n    }\n  }\n}\n```\n\nTo convert manually per string use:\n```javascript\nvar dot = require('dot-object');\n\nvar tgt = { val: 'test' };\ndot.str('this.is.my.string', 'value', tgt);\n\nconsole.log(tgt);\n\n{\n  \"val\": \"test\",\n  \"this\": {\n    \"is\": {\n      \"my\": {\n        \"string\": \"value\"\n      }\n    }\n  }\n}\n```\n\n#### Pick a value using dot notation:\n\nPicks a value from the object without removing it.\n\n```js\nvar dot = require('dot-object');\n\nvar obj = {\n some: {\n   nested: {\n     value: 'Hi there!'\n   }\n }\n};\n\nvar val = dot.pick('some.nested.value', obj);\nconsole.log(val);\n\nHi there!\n```\n\n#### Delete/Remove a value using dot notation:\n\nRemove and delete mostly behave the same, but in case of a path addressing array items:\n\n  - `delete` will re-index the array.\n  - `remove` will retain array indexes \n\n```js\nvar dot = require('dot-object');\n\nvar obj = {\n a: 'Hi There!',\n nested: {\n   array: [ \n     'Veni',\n     'Vidi',\n     'Vici',\n   ]\n }\n};\n\nvar val = dot.delete('a', obj);\nconsole.log(val);\n\nHi There!\n\n// To remove an item and directly update any array indexes use:\nvar val = dot.delete('nested.array[1]', obj);\nconsole.log(val);\n\nVidi\n\n// Remove a value but retain array indexes. \nvar val = dot.remove('nested.array[1]', obj);\n\n// To remove multiple paths at once:\nvar val = dot.remove(['nested.array[0]', 'nested.array[2]'], obj);\n```\n\n### Using modifiers\n\nYou can use modifiers to translate values on the fly.\n\nThis example uses the [underscore.string](https://github.com/epeli/underscore.string) library.\n\n\n\n```javascript\nvar dot = require('dot-object');\n\nvar _s = require('underscore.string');\n\nvar row = {\n  'nr': 200,\n  'doc.name': '    My Document   '\n};\n\nvar mods = {\n  \"doc.name\": [_s.trim, _s.underscored],\n};\n\ndot.object(row, mods);\n\nconsole.log(row);\n```\n\n```\n{\n  \"nr\": 200,\n  \"doc\": {\n    \"name\": \"my_document\"\n  }\n}\n```\n\nOr using .str() directy:\n\n```javascript\n\nvar dot = require('dot-object');\nvar _s = require('underscore.string');\nvar obj = { id: 100 };\n\n// use one modifier\ndot.str('my.title', 'this is my title', obj, _s.slugify);\n\n// multiple modifiers\ndot.str('my.title', '   this is my title  ', obj, [_s.trim, _s.slugify]);\n\nconsole.log(obj);\n```\nResult:\n```json\n{\n  \"id\": 100,\n  \"my\": {\n    \"title\": \"this-is-my-title\"\n  }\n}\n```\n\n#### Transform object\n\n```javascript\nvar dot = require('dot-object');\n\nvar source = {\n  \"id\": 1,\n  \"contact\": {\n    \"firstName\": \"John\",\n    \"lastName\": \"Doe\",\n    \"email\": \"example@gmail.com\",\n  }\n}\n\nvar recipe = {\n  'id': 'nr',\n  'contact.firstName': 'name.first',\n  'contact.lastName': 'name.last',\n  'contact.email': 'email'\n};\n\nvar tgt = {}\ndot.transform(recipe, source, tgt);\n\n// OR\n\nvar tgt = dot.transform(recipe, source);\n\nconsole.log(tgt);\n{\n  \"nr\": 1,\n  \"name\": {\n    \"first\": \"John\",\n    \"last\": \"Doe\"\n  },\n  \"email\": \"example@gmail.com\"\n}\n```\n\n\n### Convert object to dotted-key/value pair\n\n```javascript\nvar dot = require('dot-object');\n\nvar obj = {\n  id: 'my-id',\n  nes: { ted: { value: true } },\n  other: { nested: { stuff: 5 } },\n  some: { array: ['A', 'B'] }\n};\n\nvar tgt = dot.dot(obj);\n\n// or\n\nvar tgt = {};\ndot.dot(obj, tgt);\n\nconsole.log(tgt);\n```\nResult:\n```json\n{\n  \"id\": \"my-id\",\n  \"nes.ted.value\": true,\n  \"other.nested.stuff\": 5,\n  \"some.array[0]\": \"A\",\n  \"some.array[1]\": \"B\"\n}\n```\n\n### Keep array\n\nSet keepArray to true.\n\n```javascript\nvar dot = require('dot-object');\n\nvar obj = {\n  id: 'my-id',\n  other: [1, 2, 3],\n  some: { array: ['A', 'B'] }\n};\n\ndot.keepArray = true;\nvar tgt = dot.dot(obj);\n\nconsole.log(tgt);\n```\nResult:\n```json\n{\n  \"id\": \"my-id\",\n  \"other\": [1, 2, 3],\n  \"some.array\": [\"A\", \"B\"]\n}\n```\n\n## Using a different separator\n\nIf you do not like dot notation, you are free to specify a different separator.\n\n```javascript\nvar Dot = require('dot-object');\n\nvar dot = new Dot('->');\n\nvar _s = require('underscore.string');\n\nvar row = {\n  'nr': 200,\n  'doc->name': '    My Document   '\n};\n\nvar mods = {\n  \"doc->name\": [_s.trim, _s.underscored],\n};\n\ndot.object(row, mods);\n\nconsole.log(row);\n```\n\n```\n{\n  \"nr\": 200,\n  \"doc\": {\n    \"name\": \"my_document\"\n  }\n}\n```\n\n## Transforming SQL results to JSON\n\nSQL translation on the fly:\n\n```javascript\n // TODO\n\n```\n\n\n> Copyright © 2013 Rob Halff, released under the MIT license\n","publish_time":1455481178089,"_cnpm_publish_time":1455481178089,"dist-tags":{"latest":"2.1.5"}}