0

我是 Mulesoft 的新手,我正在关注快速入门指南。在第 2 步(https://developer.mulesoft.com/guides/quick-start/developing-your-first-mule-application)中,我需要以这种方式从 URI 接收变量:

[{'id' : attributes.uriParams.productId}]

但是当我尝试我的 GET 时,控制台中出现以下错误:

**消息:“无法将数组 ([{id: "2" as String {class: "java.lang.String"}}]) 强制转换为对象 1| [{'id' : attributes.uriParams.productId}] ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Trace: at main (line: 1, column : 1)" 评估表达式:"[{'id' : attributes.uriParams.productId}]"。错误类型:MULE:EXPRESSION 元素:get:\products(productId):test_daniel-config/processors/1 @ test6_db_connection:test_daniel.xml:133(选择)元素 XML:SELECT product.,CONCAT('["', (GROUP_CONCAT (variant.picture SEPARATOR '","')),'"]') AS 图片,CONCAT('[', GROUP_CONCAT('{"',variant.identifierType, '":"', variant.identifier, '" }'),']') AS identifiersFROM product INNER JOIN variant ON product。uuid = 变体.productUUIDWHERE product.uuid = :id; #[[{'id' : attributes.uriParams.productId}]] *

有任何想法吗?谢谢!

4

1 回答 1

1

当您使用应该使用对象的数组时,无法强制数组到对象错误弹出。

在上面的异常中,uri-param 应被视为 ab 对象,即包含在 {} 中,但它被视为对象数组 [{}]。

这导致了错误。

于 2018-12-19T19:50:20.800 回答