/**
在序列化对象的属性时此注解可以用来定义顺序(存在值)。
在注解声明中包括的属性将会首先被序列化(以定义时的顺序),
没有包括在定义中的属性将在后面出现。

注解定义的顺序将会覆盖隐式的顺序(列如确保Creator-Properties在non-creator属性之前序列化)

例如:
  保证确保"id"和“name”在任何其他属性之前输出
  @JsonPropertyOrder({"id", "name"})

  任何没有显示指定排序的属性使用alphabetic排序
  @JsonPropertyOrder(alphabetic=true)

  此注解可能或可能不会对反序列化有影响:基于JSON处理的
  不会有影响,但对于其他支持的数据类型(或structural conventions)可能会
  有影响

  注:在2.4版本这后,大多支持Map字母排序
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElemenetType.METHOD, 
         ElementType.CONSTRUCTOR,ElementType.FIELD})
public @interface JsonPropertyOrder{

  /**
  序列化时被注解对象的顺序
  */
  public String[] value default {};

  /**
  Property that defines waht to do regarding ordering of peroperties
  not explicitly included in annotation instance. If set to true,
  they will be alphabetically ordered; if false, order is undefined(default setting)
  */
  public boolean alphabetic() default false;
}

results matching ""

    No results matching ""