这是代码:
@RequestMapping(value="/find/city={city}", method=RequestMethod.GET)
public String getCity(@PathVariable String city) throws JsonParseException, IOException
{
ObjectMapper mapper = new ObjectMapper();
SimpleBeanPropertyFilter theFilter = SimpleBeanPropertyFilter.serializeAllExcept("id","miscellaneous","country","foundin","code","latlong","state");
FilterProvider filters = new SimpleFilterProvider().addFilter("myFilter", theFilter);
return mapper.writer(filters).writeValueAsString(City_Repository.findByCityLikeIgnoreCase(city));
}
作出回应:
[
{
"indexid": 65,
"city": "Barcelona"
},
{
"indexid": 158,
"city": "Dillons Bay"
},
{
"indexid": 232,
"city": "East London"
}]
我在回复中是必需的:
[
{
type: "airport",
"airport": { "indexid": 65, "city": "Barcelona" },
{ "indexid": 158, "city": "Dillons Bay" },
{ "indexid": 232, "city": "East London" }
]