title: Riak mapreduce error
body: <p>I am using the basic sample Riak sample provided.</p>
  
  <pre><code>5&gt; ReFun = fun(O, _, Re) -&gt; case re:run(riak_object:get_value(O), Re, [global]) of
  5&gt;     {match, Matches} -&gt; [{riak_object:key(O), length(Matches)}];
  5&gt;     nomatch -&gt; [{riak_object:key(O), 0}]
  5&gt; end end.
  #Fun&lt;erl_eval.18.50752066&gt;
  6&gt; {ok, Re} = re:compile("caremad").
  {ok,{re_pattern,0,0,0,
                  &lt;&lt;69,82,67,80,85,0,0,0,0,0,0,0,81,0,0,0,255,255,255,255,
                    255,255,...&gt;&gt;}}
  7&gt; 
  7&gt; {ok, Riak} = riakc_pb_socket:start_link("127.0.0.1", 8087).
  {ok,&lt;0.44.0&gt;}
  8&gt; riakc_pb_socket:mapred_bucket(Riak, &lt;&lt;"training"&gt;&gt;, [{map, {qfun, ReFun}, Re, true}]).
  {error,&lt;&lt;"{\"phase\":0,\"error\":\"{badfun,#Fun&lt;erl_eval.18.50752066&gt;}\",\"input\":\"{ok,{r_object,&lt;&lt;\\\"training\\\"&gt;&gt;,&lt;&lt;\\\"bam\\\"&gt;&gt;"...&gt;&gt;}
  9&gt; 
  </code></pre>
  
  <p>Looks like everything went fine except for the last step. There is no helpful information in the error except I see that the function could be syntactically wrong. I don't have any understanding of Erlang.</p>
  
  <h2>Update</h2>
  
  <p>The error I get is as follows:</p>
  
  <pre><code>curl: (3) [globbing] nested brace in column 31
  The POST body was not valid JSON.
  The error from the parser was:
  {{badmatch,any},
   [{mochijson2,tokenize,2,[{file,"src/mochijson2.erl"},{line,574}]},
    {mochijson2,decode1,2,[{file,"src/mochijson2.erl"},{line,326}]},
    {mochijson2,json_decode,2,[{file,"src/mochijson2.erl"},{line,321}]},
    {riak_kv_mapred_json,parse_request,1,
                         [{file,"src/riak_kv_mapred_json.erl"},{line,42}]},
    {riak_kv_wm_mapred,verify_body,2,
                       [{file,"src/riak_kv_wm_mapred.erl"},{line,170}]},
    {riak_kv_wm_mapred,check_body,2,
                       [{file,"src/riak_kv_wm_mapred.erl"},{line,156}]},
    {webmachine_resource,resource_call,3,
                         [{file,"src/webmachine_resource.erl"},{line,186}]},
    {webmachine_resource,do,3,
                         [{file,"src/webmachine_resource.erl"},{line,142}]}]}
  </code></pre>