I want to ignore some fields when using JSONArray:
我想在使用JSONArray时忽略一些字段:
public class Person {
private Integer id;
private String name;
//field to ignore in json
private Account account;
...
Here I use JSONArray:
在这里我使用JSONArray:
public static JSONArray listToJson(List objects) throws JSONException {
return new JSONArray(objects);
}
1 个解决方案
#1
2
You can use transient
key word for it.
您可以使用临时关键字。
private transient Account account;
Variables may be marked transient to indicate that they are not part of the persistent state of an object.
变量可以标记为瞬态,以指示它们不是对象的持久状态的一部分。
#1
2
You can use transient
key word for it.
您可以使用临时关键字。
private transient Account account;
Variables may be marked transient to indicate that they are not part of the persistent state of an object.
变量可以标记为瞬态,以指示它们不是对象的持久状态的一部分。