summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/index.js b/index.js
index 07078cc..4ff993e 100644
--- a/index.js
+++ b/index.js
@@ -18,6 +18,7 @@ function fixTemplate(t) {
function fromObject(root) {
// console.log('in ', root);
+ root = _.isObject(root) ? root : {collection: {}};
root.isCollection = function() {
return typeof this.collection == 'object';
}
@@ -29,7 +30,6 @@ function fromObject(root) {
fixTemplate(root.template);
}
else {
- root = _.isObject(root) ? root : {collection: {}};
if(!_.isObject(root.collection)) {
root.collection = {};
}
@@ -38,6 +38,7 @@ function fromObject(root) {
c.version = _.isString(c.version) ? c.version : "1.0";
c.items = _.isArray(c.items) ? c.items : [];
_.each(c.items, function(item) {
+ item.data = _.isArray(item.data) ? item.data : [];
item.links = _.isArray(item.links) ? item.links : [];
item.toObject = toObject;
});