|
@@ -1,5 +1,6 @@
|
|
|
package hello;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.sql.Connection;
|
|
|
import java.sql.PreparedStatement;
|
|
|
import java.sql.ResultSet;
|
|
@@ -7,7 +8,9 @@ import java.sql.SQLException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonGenerator;
|
|
|
import com.fasterxml.jackson.databind.*;
|
|
|
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
|
|
|
import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
|
|
|
|
|
|
/**
|
|
@@ -32,6 +35,24 @@ public class Common {
|
|
|
public final String message = "Hello, World!";
|
|
|
}
|
|
|
|
|
|
+ // Response message class with custom Jackson serializer
|
|
|
+ public static class HelloMessageCJS implements JsonSerializable {
|
|
|
+ public final String message = "Hello, World!";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void serialize(JsonGenerator jg, SerializerProvider sp) throws IOException {
|
|
|
+ jg.writeStartObject();
|
|
|
+ jg.writeStringField("message", this.message);
|
|
|
+ jg.writeEndObject();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void serializeWithType(JsonGenerator jg, SerializerProvider sp,
|
|
|
+ TypeSerializer ts) throws IOException {
|
|
|
+ throw new UnsupportedOperationException("Not needed so far.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static int normalise(String param) {
|
|
|
int count = 1;
|
|
|
try {
|