我在缓存即对象存储中有数据。我需要从缓存中获取数据并对其应用过滤条件。
这里的要求是,我必须公开 api 以获取基于 filedName 和 filedValue 的数据,这些数据将在请求中动态出现。
样品要求:
https://localhost:8082/api/customer/filter?fieldName=customerId&fieldValue=101810
我有返回代码来过滤 dataweave 中的数据,但它不起作用。你能帮忙吗
%dw 1.0
%output application/json
---
payload.rows filter (("$.content." ++ flowVars.fieldName ++ ".content") as :string == flowVars.fieldValue as :string) map ((row , indexOfRow) -> {
customerId: row.content.customerId.content as :string when row.content.customerId.content != null otherwise null,
customerName: row.content.customerName.content as :string when row.content.customerName.content != null otherwise null,
customerAddress:row.content.customerAddress.content as :string when row.content.customerAddress.content != null otherwise null
})
我得到以下错误
Exception while executing:
payload.rows filter (("$.content." ++ flowVars.fieldName ++ ".content") as :string == flowVars.fieldValue as :string) map ((row , indexOfRow) -> {
^
Type mismatch for '++' operator
found :object, :string
required :string, :string.
你能帮忙吗