Code example for JSONArray

Methods: put

0
      builder.addRiakObject("first", "key1");
      builder.map(JavascriptFunction.named("Riak.mapValuesJson"), true);
 
 
      JSONObject expected = new JSONObject();
      JSONArray inputs = new JSONArray();
      inputs.put(new String[] {"first", "key1"});
      expected.put("inputs", inputs);
      JSONArray query = new JSONArray("[{\"map\":{\"name\":\"Riak.mapValuesJson\",\"language\":\"javascript\",\"keep\":true}}]");
      expected.put("query", query);
 
      assertTrue("Generated JSON not as expected", JSONEquals.equals(expected, builder.toJSON()));
   } 
 
   @Test public void canBuildJSMapReduceJobWithObjects() throws JSONException { 
      MapReduceBuilder builder = new MapReduceBuilder();
      builder.addRiakObject("first", "key2");
      builder.map(JavascriptFunction.anon("function(v) { return [v]; }"), false);
      builder.reduce(JavascriptFunction.named("Riak.reduceMin"), true);