Search in sources :

Example 1 with FastJsonFilter

use of com.alibaba.fastjson.support.spring.annotation.FastJsonFilter in project fastjson by alibaba.

the class FastJsonViewResponseBodyAdvice method beforeBodyWriteInternal.

protected void beforeBodyWriteInternal(FastJsonContainer container, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
    FastJsonView annotation = returnType.getMethodAnnotation(FastJsonView.class);
    FastJsonFilter[] include = annotation.include();
    FastJsonFilter[] exclude = annotation.exclude();
    PropertyPreFilters filters = new PropertyPreFilters();
    for (FastJsonFilter item : include) {
        filters.addFilter(item.clazz(), item.props());
    }
    for (FastJsonFilter item : exclude) {
        filters.addFilter(item.clazz()).addExcludes(item.props());
    }
    container.setFilters(filters);
}
Also used : FastJsonFilter(com.alibaba.fastjson.support.spring.annotation.FastJsonFilter) FastJsonView(com.alibaba.fastjson.support.spring.annotation.FastJsonView)

Example 2 with FastJsonFilter

use of com.alibaba.fastjson.support.spring.annotation.FastJsonFilter in project uavstack by uavorg.

the class FastJsonViewResponseBodyAdvice method beforeBodyWriteInternal.

protected void beforeBodyWriteInternal(FastJsonContainer container, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
    FastJsonView annotation = returnType.getMethodAnnotation(FastJsonView.class);
    FastJsonFilter[] include = annotation.include();
    FastJsonFilter[] exclude = annotation.exclude();
    PropertyPreFilters filters = new PropertyPreFilters();
    for (FastJsonFilter item : include) {
        filters.addFilter(item.clazz(), item.props());
    }
    for (FastJsonFilter item : exclude) {
        filters.addFilter(item.clazz()).addExcludes(item.props());
    }
    container.setFilters(filters);
}
Also used : FastJsonFilter(com.alibaba.fastjson.support.spring.annotation.FastJsonFilter) FastJsonView(com.alibaba.fastjson.support.spring.annotation.FastJsonView)

Aggregations

FastJsonFilter (com.alibaba.fastjson.support.spring.annotation.FastJsonFilter)2 FastJsonView (com.alibaba.fastjson.support.spring.annotation.FastJsonView)2