2016-05-16 52 views
0

我有去FILE騾流1個結果 - > CHOICE - >的DataMapper - >日誌騾流僅處理從csv文件

文件端點處理具有40個記錄

的DataMapper的轉換csv文件將csv轉換爲JSON並在預覽中運行時顯示JSON格式的所有40條記錄

LOGGER將有效載荷顯示爲字節而不是JSON,並且當我將JSON轉換爲對象時,它顯示JSON格式的有效內容,但僅存在1記錄。

我的查詢: 1.您如何設置工作流以處理所有40條記錄,並將所有記錄全部轉換爲JSON並從流中全部輸出?

  1. 輸出是一個字節是否正確,因爲datamapper輸出是JSON,因此我期望在調試模式下查看負載中的JSON格式的所有記錄?
+0

您能否提供流程的XML以獲取更多上下文? – CountD

+0

你選擇的目的是什麼? –

回答

0

你可以這樣做。

<flow name="csv-to-jsonFlow"> 
     <file:inbound-endpoint path="/src/main/resources/csv" connector-ref="File" responseTimeout="10000" doc:name="File"> 
      <file:filename-regex-filter pattern=".*csv" caseSensitive="true"/> 
     </file:inbound-endpoint> 
     <dw:transform-message doc:name="Transform Message"> 
      <dw:set-payload><![CDATA[%dw 1.0 
%output application/json 
--- 
payload]]></dw:set-payload> 
     </dw:transform-message> 
     <object-to-string-transformer doc:name="Object to String"/> 
     <logger message="#[payload]" level="INFO" doc:name="Logger"/> 
    </flow> 

文件示例:

name,age,gender 
janos,29,male 
juan,40,male 
pedro,22,male 
carla,34,female 
jose,30,male 
anne,25,female 
rey,33,male 
joyce,27,female 
pia,20,female 
ard,27,male 
janos,29,male 
juan,40,male 
pedro,22,male 
carla,34,female 
jose,30,male 
anne,25,female 
rey,33,male 
joyce,27,female 
pia,20,female 
ard,27,male 
janos,29,male 
juan,40,male 
pedro,22,male 
carla,34,female 
jose,30,male 
anne,25,female 
rey,33,male 
joyce,27,female 
pia,20,female 
ard,27,male 
janos,29,male 
juan,40,male 
pedro,22,male 
carla,34,female 
jose,30,male 
anne,25,female 
rey,33,male 
joyce,27,female 
pia,20,female 
ard,27,male 

樣本輸出:

[ 
    { 
    "name": "janos", 
    "age": "29", 
    "gender": "male" 
    }, 
    { 
    "name": "juan", 
    "age": "40", 
    "gender": "male" 
    }, 
    { 
    "name": "pedro", 
    "age": "22", 
    "gender": "male" 
    }, 
    { 
    "name": "carla", 
    "age": "34", 
    "gender": "female" 
    }, 
    { 
    "name": "jose", 
    "age": "30", 
    "gender": "male" 
    }, 
    { 
    "name": "anne", 
    "age": "25", 
    "gender": "female" 
    }, 
    { 
    "name": "rey", 
    "age": "33", 
    "gender": "male" 
    }, 
    { 
    "name": "joyce", 
    "age": "27", 
    "gender": "female" 
    }, 
    { 
    "name": "pia", 
    "age": "20", 
    "gender": "female" 
    }, 
    { 
    "name": "ard", 
    "age": "27", 
    "gender": "male" 
    }, 
    { 
    "name": "janos", 
    "age": "29", 
    "gender": "male" 
    }, 
    { 
    "name": "juan", 
    "age": "40", 
    "gender": "male" 
    }, 
    { 
    "name": "pedro", 
    "age": "22", 
    "gender": "male" 
    }, 
    { 
    "name": "carla", 
    "age": "34", 
    "gender": "female" 
    }, 
    { 
    "name": "jose", 
    "age": "30", 
    "gender": "male" 
    }, 
    { 
    "name": "anne", 
    "age": "25", 
    "gender": "female" 
    }, 
    { 
    "name": "rey", 
    "age": "33", 
    "gender": "male" 
    }, 
    { 
    "name": "joyce", 
    "age": "27", 
    "gender": "female" 
    }, 
    { 
    "name": "pia", 
    "age": "20", 
    "gender": "female" 
    }, 
    { 
    "name": "ard", 
    "age": "27", 
    "gender": "male" 
    }, 
    { 
    "name": "janos", 
    "age": "29", 
    "gender": "male" 
    }, 
    { 
    "name": "juan", 
    "age": "40", 
    "gender": "male" 
    }, 
    { 
    "name": "pedro", 
    "age": "22", 
    "gender": "male" 
    }, 
    { 
    "name": "carla", 
    "age": "34", 
    "gender": "female" 
    }, 
    { 
    "name": "jose", 
    "age": "30", 
    "gender": "male" 
    }, 
    { 
    "name": "anne", 
    "age": "25", 
    "gender": "female" 
    }, 
    { 
    "name": "rey", 
    "age": "33", 
    "gender": "male" 
    }, 
    { 
    "name": "joyce", 
    "age": "27", 
    "gender": "female" 
    }, 
    { 
    "name": "pia", 
    "age": "20", 
    "gender": "female" 
    }, 
    { 
    "name": "ard", 
    "age": "27", 
    "gender": "male" 
    }, 
    { 
    "name": "janos", 
    "age": "29", 
    "gender": "male" 
    }, 
    { 
    "name": "juan", 
    "age": "40", 
    "gender": "male" 
    }, 
    { 
    "name": "pedro", 
    "age": "22", 
    "gender": "male" 
    }, 
    { 
    "name": "carla", 
    "age": "34", 
    "gender": "female" 
    }, 
    { 
    "name": "jose", 
    "age": "30", 
    "gender": "male" 
    }, 
    { 
    "name": "anne", 
    "age": "25", 
    "gender": "female" 
    }, 
    { 
    "name": "rey", 
    "age": "33", 
    "gender": "male" 
    }, 
    { 
    "name": "joyce", 
    "age": "27", 
    "gender": "female" 
    }, 
    { 
    "name": "pia", 
    "age": "20", 
    "gender": "female" 
    }, 
    { 
    "name": "ard", 
    "age": "27", 
    "gender": "male" 
    } 
] 

希望這有助於。