public void to(WebContext context) {
		if (entity == null) {
			return;
		}
		
		HttpServletResponse response = context.response();
		
		try {
			response.setCharacterEncoding("UTF-8");
			response.setHeader("Content-Type", mediaType);
			
			if (status > 0) {
				response.setStatus(status);
			}
			
			if (entity instanceof String) {
				response.getWriter().write((String) entity);
				return;
			}
			
			GsonBuilder builder = new GsonBuilder();
			Set<Class<?>> classes = new HashSet<Class<?>>();
			parse(entity.getClass(), classes);
			
			for (Class<?> clazz : classes) {
				builder.registerTypeAdapter(clazz, new ValueTypeJsonSerializer<Object>());
			}
			
			// XXX: Any options?
			Gson gson = builder.create();
			response.getWriter().write(gson.toJson(entity));
		} catch (IOException e) {
			throw new UncheckedException(e);
		}
	}
public void to(WebContext context) {
		if (entity == null) {
			return;
		}
		
		HttpServletResponse response = context.response();
		
		try {
			response.setCharacterEncoding("UTF-8");
			response.setHeader("Content-Type", mediaType);
			
			if (status > 0) {
				response.setStatus(status);
			}
			
			if (entity instanceof String) {
				response.getWriter().write((String) entity);
				return;
			}
			
			GsonBuilder builder = new GsonBuilder();
			Set<Class<?>> classes = new HashSet<Class<?>>();
			parse(entity.getClass(), classes);
			
			for (Class<?> clazz : classes) {
				builder.registerTypeAdapter(clazz, new ValueTypeJsonSerializer<Object>());
			}
			
			
			Gson gson = builder.create();
			response.getWriter().write(gson.toJson(entity));
		} catch (IOException e) {
			throw new UncheckedException(e);
		}
	}
public void to ( WebContext context ) { if ( entity == null ) { return ; } HttpServletResponse response = context . response ( ) ; try { response . setCharacterEncoding ( "UTF-8" ) ; response . setHeader ( "Content-Type" , mediaType ) ; if ( status > 0 ) { response . setStatus ( status ) ; } if ( entity instanceof String ) { response . getWriter ( ) . write ( ( String ) entity ) ; return ; } GsonBuilder builder = new GsonBuilder ( ) ; Set < Class < ? > > classes = new HashSet < Class < ? > > ( ) ; parse ( entity . getClass ( ) , classes ) ; for ( Class < ? > clazz : classes ) { builder . registerTypeAdapter ( clazz , new ValueTypeJsonSerializer < Object > ( ) ) ; } // XXX: Any options? Gson gson = builder . create ( ) ; response . getWriter ( ) . write ( gson . toJson ( entity ) ) ; } catch ( IOException e ) { throw new UncheckedException ( e ) ; } }
Writes {@code JSONResponse} to the current {@code WebContext}.

@param context The current {@code WebContext}.
Writes { @code JSONResponse } to the current { @code WebContext } .