io.castle.client.internal.json.StringJsonSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of castle-java Show documentation
Show all versions of castle-java Show documentation
Castle adds real-time monitoring of your authentication stack, instantly notifying you and your users
on potential account hijacks.
package io.castle.client.internal.json;
import com.google.gson.*;
import java.lang.reflect.Type;
public class StringJsonSerializer implements JsonSerializer {
@Override
public JsonElement serialize(String src, Type typeOfSrc, JsonSerializationContext context) {
if (src == null) {
return JsonNull.INSTANCE;
}
if( src.length() > 2048) {
return new JsonPrimitive(src.substring(0,2048));
}
return new JsonPrimitive(src);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy