@Override
    public void writeTo(Movie movie, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
        JsonGenerator gen = Json.createGenerator(entityStream);
        gen.writeStartObject()
                .write("id", movie.getId())
                .write("name", movie.getName())
                .write("actors", movie.getActors())
                .writeEnd();
        gen.flush();
    }