簡體   English   中英

在Java中使用JSONArray時如何忽略字段

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM