package hellowicket;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.wicket.request.resource.AbstractResource;
import com.fasterxml.jackson.databind.*;

public class HelloJsonResponse extends AbstractResource
{
	private static final long serialVersionUID = 1L;
	
	private static final ObjectMapper mapper = new ObjectMapper();

	protected ResourceResponse newResourceResponse(Attributes attributes)
	{
    ResourceResponse response = new ResourceResponse();
    response.setContentType("application/json");
    response.setWriteCallback(new WriteCallback() {
      public void writeData(Attributes attributes)
      {
        Map<String, String> data = new HashMap<String, String>();
        data.put("message", "Hello, world");

        try
        {
          attributes.getResponse().write(HelloJsonResponse.mapper.writeValueAsString(data));
        }
        catch (IOException ex)
        {
          // do nothing
        }
      }
    });
    return response;
	}
}

@@ -765,13 +765,14 @@
 lo, 
-w
+W
 orld
+!
 %22);%0A

verify Fixed wicket's json test