跳到主要内容
版本:5.0.1

RemoveJsonAttributesResponseBody GatewayFilter 工厂

DeepSeek V3 中英对照 RemoveJsonAttributesResponseBody GatewayFilter Factory RemoveJsonAttributesResponseBody GatewayFilter Factory

RemoveJsonAttributesResponseBody GatewayFilter 工厂接收一个 attribute names(属性名称)集合进行搜索,最后一个可选参数可以是布尔值,用于指定仅在根级别删除属性(如果参数配置末尾未指定,则默认为 false)或递归删除(true)。它提供了一种便捷的方法,通过删除 JSON 正文内容中的属性来对其应用转换。

以下示例配置了一个 RemoveJsonAttributesResponseBody GatewayFilter:

spring:
cloud:
gateway:
routes:
- id: removejsonattributes_route
uri: https://example.org
filters:
- RemoveJsonAttributesResponseBody=id,color

这将从JSON内容体的根级别移除属性"id"和"color"。

以下示例配置了一个使用可选最后一个参数的 RemoveJsonAttributesResponseBody GatewayFilter:

spring:
cloud:
gateway:
routes:
- id: removejsonattributes_recursively_route
uri: https://example.org
predicates:
- Path=/red/{segment}
filters:
- RemoveJsonAttributesResponseBody=id,color,true

这将从JSON内容体中的任何层级移除属性"id"和"color"。