In your WebPage...

...

public class JsonWebPage extends WebPage {

	public JsonWebPage(PageParameters pageParameters) {

		getRequestCycle().scheduleRequestHandlerAfterCurrent(new IRequestHandler() {

			@Override
			public void detach(RequestCycle requestCycle) {
				// Nothing to do here.
			}

			@Override
			public void respond(RequestCycle requestCycle) {
				// Add JSON-encoded string to the response.
				Response response = requestCycle.getResponse();
                                response.setContentType("application/json");
                                response.write("{\"jsonKey\":\"jsonValue\"}");
			}
		});
	}
}
...

You can use TextRequestHandler to simplify the code above.

NOTE: You DO NOT need to manually write JSON response, there are libraries like http://json-lib.sourceforge.net/ available that will allow you to convert an object hierarchy to something more useful in terms of JSON rather easily. For details, check the documentation at: http://json-lib.sourceforge.net/usage.html.

Another library for JSON processing/generation is jackson.

NOTE Wicket >= 1.5.x: see https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/autocomplete-tagit-parent for an example