anchor.diff:      end.
   
   verify_body(Body, State) ->
  -    case mochijson2:decode(Body) of
  +    case catch mochijson2:decode(Body) of
           {struct, MapReduceDesc} ->
               Inputs = proplists:get_value(?INPUTS_TOKEN, MapReduceDesc),
               Query = proplists:get_value(?QUERY_TOKEN, MapReduceDesc),
  
positive.code:                         {ok, ParsedInputs} ->
                              case riak_mapred_json:parse_query(Query) of
                                  {ok, ParsedQuery} ->
                                      {true, State#state{inputs=ParsedInputs, mrquery=ParsedQuery}};
                                  error ->
                                      {false, State}
                              end;
                          error ->
                              {false, State}
                      end;
                  false ->
                      {false, State}
              end
      end.
  
negative.code:     end.
  
  allowed_methods(RD, State) ->
      {['GET','HEAD','POST'], RD, State}.
  
  malformed_request(RD, State) ->
      {Verified, Message, NewState} =
          case {wrq:method(RD), wrq:req_body(RD)} of
              {'POST', Body} when Body /= undefined ->
                  verify_body(Body, State);
              _ ->
                  {false, usage(), State}
          end,
      {not Verified,
       if Verified -> RD;
          true ->
               wrq:set_resp_header(
                 "Content-Type", "text/plain",
                 wrq:set_resp_body(Message, RD))
       end,
       NewState}.
  
  content_types_provided(RD, State) ->
      {[{"application/json", nop}], RD, State}.
  
  nop(RD, State) ->
      {usage(), RD, State}.
  
  process_post(RD, #state{inputs=Inputs, mrquery=Query}=State) ->
      Me = self(),
  