Comparing version
@@ -140,3 +140,3 @@ var path = require('path'); | ||
this._setValueForKeyPath = function(key_path, value) { | ||
var key_array = key_path.split('.'); | ||
var key_array = key_path.replace('..', '').split('.'); | ||
var tip_key = key_array.pop(); | ||
@@ -143,0 +143,0 @@ var parent_path = key_array.join('.'); |
{ | ||
"name": "dot-json", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Easily edit a json file from the CLI or NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "lib/dot-json.js", |
@@ -19,2 +19,3 @@ # dot-json | ||
dot-json myfile.json user.email "john@example.com" | ||
dot-json myfile.json foo..bar baz | ||
``` | ||
@@ -27,3 +28,4 @@ myfile.json now looks like | ||
"email": "john@example.com" | ||
} | ||
}, | ||
"foo.bar": "baz" | ||
} | ||
@@ -30,0 +32,0 @@ ``` |
@@ -314,2 +314,8 @@ var expect = require('chai').expect; | ||
it("should be able to set a dotted property on object", function() { | ||
var dot_json = new DotJson(); | ||
dot_json.set("foo..bar", "baz"); | ||
expect(JSON.stringify(dot_json._object)).equal(JSON.stringify({"foo.bar": "baz"})); | ||
}); | ||
it("should be able to set a property on a prepared key path", function() { | ||
@@ -316,0 +322,0 @@ var dot_json = new DotJson(); |
37114
1.1%6
20%1165
1.04%128
1.59%