io.paymenthighway.json.JsonGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of paymenthighway Show documentation
Show all versions of paymenthighway Show documentation
Payment Highway Java API Library
package io.paymenthighway.json;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Generates JSON from objects
*/
public class JsonGenerator {
/**
* Constructor
*/
public JsonGenerator() {
}
public String createTransactionJson(Object request) {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
String json = null;
try {
json = mapper.writeValueAsString(request);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return json;
}
}