I have accomplished this by using JSON stringify.
var store = {
clear : function (key) {
return amplify.store(key, null);
},
fetch : function (key) {
var val = amplify.store(key);
return JSON.parse(val);
},
save: function (key, value) {
var val = JSON.stringify(value);
amplify.store(key, val, expires);
},
saveSession: function (key, value) {
if (!amplify.store.types.sessionStorage) {
this.save(key, value);
}
else {
var val = JSON.stringify(value);
amplify.store.sessionStorage(key, val);
}
},
fetchSession: function (key) {
if (!amplify.store.types.sessionStorage) {
return this.fetch(key);
}
else {
var val = amplify.store.sessionStorage(key);
return JSON.parse(val);
}
}
};
Hope this will help you and others.