1

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);

}
Yan.F
  • 630
  • 5
  • 20
  • Please refer link: http://stackoverflow.com/questions/7421474/how-can-i-tell-jackson-to-ignore-a-property-for-which-i-dont-have-control-over – 2787184 Dec 14 '16 at 11:46
  • I tried @JsonIgnore already, it's not working for me. – Yan.F Dec 14 '16 at 14:17

1 Answers1

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.

Antony Dao
  • 425
  • 2
  • 14