title: Best way to build REST api for a search with operands JSON
body: <p>I'm trying to build a REST api for my application. The basics are done. But now I need some help to for a search with different parameters and their operands. </p>
  
  <p>Let's say I have a JSON String like this:</p>
  
  <pre><code>{"v00Datvon":"09-07-2014","v00Datbis":"09-07-2014","v00Saicode":{"saiCode":"SO02"}}
  </code></pre>
  
  <p>These are values of my "contract" domain object.</p>
  
  <p>For the search at the UI part, you can choose for the two dates an operand (greater or less or equals) </p>
  
  <p>All the parameters (without the operands) are sent per GET and Ajax call.</p>
  
  <p>The Spring MVC Controller looks like this:</p>
  
  <pre><code>    @RequestMapping(value = "/", method = RequestMethod.GET, headers = "Accept=application/json")
      public ResponseEntity&lt;String&gt; getContractsFromSearch(@RequestParam String allRequestParams, ModelMap model){
      //some stuff
      }
  </code></pre>
  
  <p>I'm looking for technical input, how to add the operands to the JSON String and Controller in a clean and good way. I dont want to hack some bad code. 
  If you need more input, please leave a comment.
  Thanks!</p>
  
  <p><strong>Update 1.</strong></p>
  
  <p>GET Request:</p>
  
  <pre><code>allRequestParams={"v00Datvon":"09-07-2014","v00Datbis":"09-07-2014","v00Saicode":{"saiCode":"SO02"}}
  </code></pre>
  
  <p><strong>Update 2.</strong></p>
  
  <pre><code>    {
    "dateFrom": {
      "dateFrom": "someDate",
      "operand": "less"
    },
    "dateTo": {
      "dateTo": "someDate",
      "operand": "greater"
    },
    "season": {
      "season": "someSeason",
      "operand": "equals"
    }
  }
  </code></pre>
  
  <p><strong>Update 3</strong>
  Deserialization:</p>
  
  <pre><code>public static Contract fromJsonToContract(String json) {
      return new JSONDeserializer&lt;Contract&gt;().use(Calendar.class, new CalendarTransformer("dd-MM-yyyy HH:mm")).use(null, Contract.class).deserialize(json);
  }
  </code></pre>