0

this is the code:

public class RestApi_Controller {


@Autowired
public AirportRepo Airport_Repository;

@RequestMapping(value="/airport/{indexid}", method=RequestMethod.GET)
public List<Master_Airport> getAirportIndexid(@PathVariable int indexid)
{

    return Airport_Repository.findByIndexid(indexid);
  }
 }

Can any one help me out using json filter??

Airport Collection contains:

private int indexid;
private String airportcode;
private String airportname;
private String code;
Naresh Gounder
  • 113
  • 1
  • 1
  • 5
  • Possible duplicate of [How to add and ignore a field for json response](http://stackoverflow.com/questions/8892937/how-to-add-and-ignore-a-field-for-json-response) – kryger Jul 11 '16 at 10:25

1 Answers1

1

You can use Jackson Annotations to achieve this.

Add Jackson dependency or its jars to your code and annotate the fields like this:

@JsonIgnore
private int indexid;
private String airportcode;
@JsonIgnore
private String airportname;
private String code;

This will ignore indexid and airportname in the response.

More details can be found here

Sampada
  • 2,931
  • 7
  • 27
  • 39