Permalink
Browse files

add json.js and update /lib/index.js

  • Loading branch information...
1 parent 1b93404 commit db6a246bf07378244c504faa9a785f85935fd009 @lenbo-ma committed with Mar 19, 2013
Showing with 23 additions and 1 deletion.
  1. +3 −1 lib/index.js
  2. +20 −0 lib/json.js
View
@@ -9,4 +9,6 @@ exports.version = '0.0.1';
//node url patch
require('./url');
//node prototype
-require('./prototype');
+require('./prototype');
+//node json util
+require('./json');
View
@@ -0,0 +1,20 @@
+/**
+ * Json Utils
+ * Author: Lenbo Ma
+ * E-mail: mlongbo@gmail.com
+ */
+
+/**
+ * 合并多个json对象
+ * @param {Array} jsonArr
+ * @return {Object} newJson
+ */
+exports.merge = function (jsonArr) {
+ var newJson = {};
+ for (var index in jsonArr) {
+ for (var attr in jsonArr[index]) {
+ newJson[attr] = jsonArr[index][attr];
+ }
+ }
+ return newJson;
+};

0 comments on commit db6a246

Please sign in to comment.