[英]How to Ignore fields when using JSONArray in Java
我想在使用JSONArray時忽略一些字段:
public class Person {
private Integer id;
private String name;
//field to ignore in json
private Account account;
...
在這里我使用JSONArray:
public static JSONArray listToJson(List objects) throws JSONException {
return new JSONArray(objects);
}
您可以為其使用transient
關鍵字。
private transient Account account;
變量可以標記為瞬態,以指示它們不是對象持久狀態的一部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.