How to save Objects in local storage in Chrome + JavaScript

local storage limited to handle only string key/value pairs you can do like below using JSON.stringify and while getting value JSON.parse

var testObject = {name:"test", time:"Date 2017-02-03T08:38:04.449Z"};
Put the object into storage:

localStorage.setItem('testObject', JSON.stringify(testObject));
localStorage['testObject'] = JSON.stringify(testObject));

Retrieve the object from storage:
var retrievedObject = localStorage.getItem('testObject');
var retrievedObject = localStorage['testObject'];

console.log('retrievedObject: ', JSON.parse(retrievedObject));