title: Storing a list of key value pairs in a url parameter, javascript.
body: <p>Assuming <code>www.mydomain.com?param1=example</code> as an example.</p>
  
  <p>What is the best way to store a second parameter that is a list of key value pairs?  At the minute I use <code>&amp;param2=key|value,key|value</code>.  I separate the key from the value using a vertical line, and the pairing with a comma, everything after the equals is encoded using <code>encodeURIComponent()</code>.  This works fine.  </p>
  
  <p>However, the user has control of the value... And as sensible human beings we all know that the first thing the user will probably do is stick a vertical bar or a comma as one of the values breaking my parameter parser.  Is there a better way to do this?  I've seen PHP users talking about storing associated arrays in urls but I'm looking for a <em>pure javascript solution</em>.</p>