title: Parsing JSON from request parameters in a HttpServlet
body: <p>I need to implement a parser which parses some values from "JSON strings". The data is accessible from the request parameters as follows:</p>
  
  <blockquote>
    <p>String[] criterion = request.getParameterValues("criteria");</p>
  </blockquote>
  
  <p>The criterion contains the following strings (each row represents a String):</p>
  
  <pre><code>{"fieldName":"name","operator":"iContains","value":"a string"}
  {"fieldName":"date","operator":"equals","value":"2013-02-26"}
  {"fieldName":"amount","operator":"equals","value":2600}
  </code></pre>
  
  <p>I need to be able to get the values from criterion by fieldName. The API could be like this:</p>
  
  <pre><code>String name = CoolParserUtil.parseParam(criterion, "name", String.class);
  // "a string"
  Date date = CoolParserUtil.parseParam(criterion, "date", Date.class);
  // date representing 2013-02-26
  // etc. etc.
  </code></pre>
  
  <p>How would you implement the parser?</p>