Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
package routines;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;
public class XmlToJSON {
public static String xmlToJson(String xml){
String json ="";
try {
JSONObject xmlJSONObj = XML.toJSONObject(xml);
json = xmlJSONObj.toString();
} catch (JSONException je) {
System.out.println(je.toString());
}
return json;
}
}
Hi, if JSON content is already available, then return it as String or byte[], and if this content is zipped/etc then indeed you can customize Content-Type in tRESTResponse/Advanced properties. I think it is important that the studio can be eventually enhanced to support InputStream too.
Cheers, Sergey
Bryan,
To return JSON in your response all you need to do is use content negotiation on the client side. Make sure the client is sending a header of Accept: application/json and Talend should do the conversion automatically.
I've written a blog post on this - see http : // integrationwire.com/talend/how-to-return-a-json-response-from-a-talend-job/ (I can't add this as a link because I don't have enough posts yet)