我很困难,需要一些建议来评估WSO2 ESB。
我在JSON中有一个请求有效负载,如下所示。
{
names:
[
{
“name”:”niraj”
},
{
“name=”atul”
}
]
}
我需要逐个迭代$ body / names / name并创建一个JSON数组,如下所示。
{
resp:
[
{
“name”:”niraj”,
“city”:”pune”
},
{
“name”:”atul”,
“city”:”mumbai”
}
]
}
我面临的问题是我无法在WSO2 ESB中的foreach mediator中创建JsonArray。我看不到在WSO2 ESB中定义/使用JsonArray的任何选项。
如果您有任何建议,请提出建议。
我已编码如下。
<foreach expression="$body/Children/Children" id="f4">
<sequence>
<filter xpath="$body/Children/_JsonReader_PS_type and $body/Children/_JsonReader_PS_type='Entity' and $body/Children/PrimaryKey='true' and $body/Children/Items/FirstName/Value ">
<then>
<log level="custom">
<property name="logger" value="I am inside 8 Filter"/>
<property expression="$body/Children/Items/FirstName/Value" name="firstName"/>
<property expression="$body/Children/Items/LastName/Value" name="lastName"/>
<property expression="$body/Children/Items/PersonNumber/Value" name="ssn"/>
</log>
<property expression="$body/Children/Items/FirstName/Value" name="firstName" scope="default" type="STRING"/>
<property expression="$body/Children/Items/LastName/Value" name="lastName" scope="default" type="STRING"/>
<property expression="$body/Children/Items/PersonNumber/Value" name="ssn" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format>{
"First Name" : "$1",
"Last Name" : "$2",
"SSN" : "$3"
}</format>
<args>
<arg evaluator="xml" expression="get-property('firstName')"/>
<arg evaluator="xml" expression="get-property('lastName')"/>
<arg evaluator="xml" expression="get-property('ssn')"/>
</args>
</payloadFactory>
<log>
<property expression="json-eval($.)" name="JSON-Payload"/>
</log>
</then>
<else/>
</filter>
</sequence>
</foreach>
谢谢!