Reputation: 640
I want to ignore some fields when using JSONArray:
public class Person {
private Integer id;
private String name;
//field to ignore in json
private Account account;
...
Here I use JSONArray:
public static JSONArray listToJson(List objects) throws JSONException {
return new JSONArray(objects);
}
Upvotes: 1
Views: 291
Reputation: 425
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.
Upvotes: 2