title: export Data in localStorage for later re-import
body: <p>I want to export a few items from my localStorage to save it externally but in a format so that I can import it again later.</p>
  
  <p>My attempt was to write executable code that can be pasted later in a textarea. Then the value of that textare will simply be eval()ed.</p>
  
  <p>Problem: The data stored in localStorage were stored as</p>
  
  <pre class="lang-js prettyprint-override"><code>var data = [];
  data.push('sampledata');
  data.push({sample: 'object'});
  localStorage.setItem('varname',data);
  </code></pre>
  
  <p>So it contains various chars I don't like, like ', " etc</p>
  
  <p>My (not working) solution so far was:</p>
  
  <pre class="lang-js prettyprint-override"><code>var container = $('#localDataContainer');
  container.append('localStorage.setItem("cockpitLastVisited","' + localStorage.getItem("cockpitLastVisited") + '");&lt;br/&gt;');
  container.append('localStorage.setItem("cockpit_services","' + localStorage.getItem("cockpit_services") + '");&lt;br/&gt;');
  container.append('localStorage.setItem("cockpit_users","' + localStorage.getItem("cockpit_users") + '");');
  </code></pre>
  
  <p>If my attempt seems to be OK, what is the best way to create code that can then be executed the way it is?</p>