Following code can be used to decompress a JSON File
public static byte[] decompress(byte[] data) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try{
IOUtils.copy(new GZIPInputStream(new ByteArrayInputStream(data)), out);
} catch(IOException e){
throw new RuntimeException(e);
}
return out.toByteArray();
}
and in our MessageListener implemented class use this code
byte[] decompressmessage = decompress(messageContent);
YourClass objYourClass = mapper.readValue(new String(decompressmessage), YourClass.class);
//YourClass code
import org.codehaus.jackson.annotate.JsonProperty;
public class YourClass {
@JsonProperty("EventNo") public String eventNo;
public String getEventNo() {
return eventNo;
}
public void setEventNo(String eventNo) {
this.eventNo = eventNo;
}
}
No comments:
Post a Comment