Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SerializeFilter when return entity through FastJSON #426

Closed
wd0472 opened this issue Nov 29, 2017 · 1 comment
Closed

Support SerializeFilter when return entity through FastJSON #426

wd0472 opened this issue Nov 29, 2017 · 1 comment

Comments

@wd0472
Copy link

wd0472 commented Nov 29, 2017

At the moment I have to do in the following way to apply SerializeFilter to JSON response:

	@GetAction("/")
	public RenderJSON hospitalInfo() {
		List<RSHospitalInfo> list = new ArrayList<RSHospitalInfo>();
		RSHospitalInfo hospital = new RSHospitalInfo();
		hospital.setHospitalName("中山第一人民医院");
		hospital.setId(SnowflakeIdWorker.getSnowflakeId());
		hospital.setCreateTime(new Date());
		hospital.setUpdateTime(new Date());
		list.add(hospital);
		List<Map<String, String>> parseObject = JSONArray.parseObject(
				JSON.toJSONString(list, new BeanPropertyFilter()), List.class);
		return renderJson(parseObject);
	}

Can we provide better support for developer to specify SerializeFilter in Act application?

The demo app: https://pan.baidu.com/s/1slogSOH

@greenlaw110 greenlaw110 changed the title 期望后台数据返回前台支持SerializeFilter Support SerializeFilter when return entity through FastJSON Dec 3, 2017
@greenlaw110 greenlaw110 added this to the 1.6.0 milestone Dec 3, 2017
@actframework actframework deleted a comment from wd0472 Dec 4, 2017
@greenlaw110
Copy link
Contributor

Now you can do it in the following way:

	@GetAction("/")
	@ResponseContentType(H.MediaType.JSON)
	@FastJsonFilter(BeanPropertyFilter.class)
	public Object hospitalInfo() {
		List<RSHospitalInfo> list = new ArrayList<RSHospitalInfo>();
		RSHospitalInfo hospital = new RSHospitalInfo();
		hospital.setHospitalName("中山第一人民医院");
		hospital.setId(SnowflakeIdWorker.getSnowflakeId());
		hospital.setCreateTime(new Date());
		hospital.setUpdateTime(new Date());
		list.add(hospital);
		return list;
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants