【发布时间】:2016-01-25 09:05:21
【问题描述】:
我有这个:
{a=1, b=2, c=3}, {a2=1, b2=2, c2=3}, {a3=1, b3=2, c3=3},
我需要这样的 json 输出:
[{"a":"1", "b":"2", "c":"3"}, {"a2":"1", "b2":"2", "c2":"3"}, {"a3":"1", "b3:2", "c3:3"}]
如何在 Mule CE 中执行此操作?有什么建议吗?
编辑:
我已经从 magento <magento:list-products/> 返回数据,并像这样转换了有效负载:
<json:object-to-json-transformer doc:name="Object to JSON"/>
<json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object"/>
我必须对该有效负载进行一些过滤:使用了<foreach/>,并且对于每个符合条件的产品,我都保存在这样的变量中:
<set-variable variableName="productsInfoArr"
value="#[flowVars.productsInfoArr.concat(flowVars.productInfo)+',']"/>
所以结果如上...
所以基本上问题是:如何使用 json 项创建数组?
【问题讨论】: