001package org.nuxeo.template.xdocreport.jaxrs; 002 003import java.io.IOException; 004import java.io.OutputStream; 005 006import org.codehaus.jackson.JsonGenerator; 007import org.nuxeo.ecm.automation.jaxrs.io.JsonHelper; 008 009import fr.opensagres.xdocreport.remoting.resources.domain.Resource; 010 011/** 012 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a> 013 */ 014public class JSONHelper { 015 016 public static void writeResource(Resource resource, OutputStream out) throws IOException { 017 String prefix = "{ \"resource\" : { \"name\" : \"resources\", \"type\" : \"CATEGORY\", \"children\" : "; 018 String suffix = " }}"; 019 out.write(prefix.getBytes()); 020 JsonGenerator gen = JsonHelper.createJsonGenerator(out); 021 gen.writeObject(resource); 022 out.write(suffix.getBytes()); 023 } 024 025}