Code example for JsonPrimitive

0
 
    private static final Type TYPE = SupplementaryTypes.FREQUENCY;
 
    @Override 
    public JsonElement serialize(Frequency src, Type typeOfSrc, JsonSerializationContext context) {
        return new JsonPrimitive(src.getFrequency().toPlainString());
    } 
 
    @Override 
    public Frequency deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        return new Frequency(new ScaleInvariantBigDecimal(json.getAsString()));
    } 
 
    @Override 
    public Type getType() {
        return TYPE;
    } 
} 
Experience pair programming with AI  Get Codota for Java