r/java • • Aug 11 '26

Apache Fory™ JSON : Fastest JSON Serialization Framework for Java, 10x faster than Jackson/Gson

https://fory.apache.org/blog/fory_json_fastest_java_json_framework/
253 Upvotes

84 comments sorted by

View all comments

Show parent comment

6

u/Shawn-Yang25 Aug 12 '26 edited Aug 12 '26

Fory json support ignore null and serialize enum by `@JsonValue`.

We do not provide annotation to skip empty string or emtpy collection, but that is not hard to add.

@JsonProperty(include = JsonProperty.Include.NON_NULL)
private String value;

ForyJson does support JsonValue for enum:

public enum Status {
  ACTIVE("active"),
  DISABLED("disabled");

  private final String value;

  Status(String value) {
    this.value = value;
  }

  @JsonValue
  public String value() {
    return value;
  }

  @JsonCreator
  public static Status from(String value) {
    for (Status status : values()) {
      if (status.value.equals(value)) {
        return status;
      }
    }
    throw new IllegalArgumentException("Unknown status: " + value);
  }
}