Unflattening view data to JSON with Mule DataMapper

I've got a database view that I need to send to a Web API call in JSON format, but I'm having a hard time figuring out how to get the datamapper to un-flatten the data. The format I want to get to is something like: { "PersonId": "12345" , "CommonProp": "asdf" , "DataForPerson": [ { "Prop1": "prop 1 value A", "Prop2": "prop 2 value A" } , { "Prop1": "prop 1 value B", "Prop2": "prop 2 value B" } ] } The format coming in from the view is something like: PersonId CommonProp Prop1 Prop2 12345 asdf prop 1 value A prop 2 value A 12345 asdf prop 2 value B prop 2 value B How can I go about doing this? The closest I've gotten is { "PersonId": "12345" , "CommonProp": "asdf" , "DataForPerson": [ { "Prop1": "prop 1 value A", "Prop2": "prop 2 value A" } ] } { "PersonId": "12345" , "CommonProp": "asdf" , "DataForPerson": [ { "Prop1": "prop 1 value B", "Prop2": "prop 2 value B" } ] } Obviously, this is not correct. I'd tried to use the datamapper to do this, but didn't have any luck. Thanks! ***edit*** Here's a picture of the flow: ![Mule Flow][1] The poll and the JDBC are a `SELECT DISTINCT PERSON_ID FROM MY_VIEW`. In the for each, I was hoping to make one JSON call per person. I'm outputting to a file right now instead of invoking the Web API, though I did try the Web API call, and it works fine so long as it gets valid JSON. [1]: http://i.stack.imgur.com/yQjWK.png
Just to be clear: the data source type is CSV?

以上就是Unflattening view data to JSON with Mule DataMapper的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JSON 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏