node-json-transform
Advanced tools
Comparing version 1.0.2 to 1.0.3
24
index.js
@@ -21,10 +21,14 @@ // DataTransform | ||
key = key || map.list, | ||
keys = null; | ||
if(key == "") { | ||
value = ""; | ||
} else { | ||
keys = key.split('.'); | ||
for(var i = 0; i < keys.length; i++ ) { | ||
if(typeof(value) !== "undefined" && | ||
value[keys[i]]) { | ||
value = value[keys[i]]; | ||
} else { | ||
return null; | ||
for(var i = 0; i < keys.length; i++ ) { | ||
if(typeof(value) !== "undefined" && | ||
value[keys[i]]) { | ||
value = value[keys[i]]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
@@ -66,3 +70,7 @@ } | ||
_.each(map.item, _.bind(function(oldkey, newkey) { | ||
obj[newkey] = this.getValue(item, oldkey); | ||
if(typeof(oldkey) == "string" && oldkey.length > 0) { | ||
obj[newkey] = this.getValue(item, oldkey); | ||
} else { | ||
obj[newkey] = ""; | ||
} | ||
}, this)); | ||
@@ -69,0 +77,0 @@ return obj; |
{ | ||
"name": "node-json-transform", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A node module for transforming and performing operations on JSON.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "node_modules/jasmine-node/bin/jasmine-node test/" | ||
}, | ||
@@ -26,3 +26,7 @@ "repository": { | ||
"underscore": "^1.7.0" | ||
}, | ||
"devDependencies": { | ||
"jasmine-node": "^1.14.5", | ||
"underscore": "^1.8.3" | ||
} | ||
} |
@@ -31,3 +31,4 @@ # node-data-transform | ||
} | ||
] | ||
], | ||
clearMe: "text" | ||
} | ||
@@ -49,3 +50,4 @@ ] | ||
link: "extra.link", | ||
item: "list1.0.name" | ||
item: "list1.0.name", | ||
clearMe: "" | ||
}, | ||
@@ -77,3 +79,4 @@ operate: [ | ||
link: "http://goo.cm", | ||
info: "mike" | ||
info: "mike", | ||
clearMe: "" | ||
}] | ||
@@ -84,2 +87,6 @@ ``` | ||
## Changelog | ||
1.0.3 Added the ability to clear and set field by passing an empty string in the map. | ||
## Credits | ||
@@ -86,0 +93,0 @@ |
6878
5
150
113
2