Quick way to return JSON from your HTTP Provider

This is a convenient built-in way to return json from your HTTP Provider (within a Wowza):

public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {

HashMap<String,String> dataObj =  new HashMap<String,String>();
dataObj.put(“test”,”value”);

try {

ObjectMapper mapper = new ObjectMapper();
OutputStream out = resp.getOutputStream();
byte[] outBytes = mapper.writeValueAsString(response).getBytes();
out.write(outBytes);

} catch (Exception e) {
WMSLoggerFactory.getLogger(null).error(
“ApplicationInfo: ” + e.toString());
}
}


Comments are closed.