請參閱本dataweave窗口形象: - dataweave window imageCSV到JSON使用dataweave
我試圖改變一個CSV到JSON使用dataweave但即使是最簡單的變換會自動創建一個空標籤。我可以在預覽窗口中看到。當我運行該應用程序我得到這個錯誤 *
Exception stack is: 1. 452 (java.lang.ArrayIndexOutOfBoundsException) com.mulesoft.weave.reader.CharArraySourceReader:21 (null) 2. 452 (java.lang.ArrayIndexOutOfBoundsException). Message payload is of type: WeaveMessageProcessor$WeaveOutputHandler (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32******************************************************************************** Root Exception stack trace: java.lang.ArrayIndexOutOfBoundsException: 452 at com.mulesoft.weave.reader.CharArraySourceReader.lookAheadAscii(CharArraySourceReader.scala:21) at com.mulesoft.weave.reader.csv.parser.CSVParser.parse(CSVParser.scala:132) at com.mulesoft.weave.reader.csv.parser.CSVParser.elementAt(CSVParser.scala:61) at com.mulesoft.weave.reader.csv.parser.CSVParser.contains(CSVParser.scala:38) at com.mulesoft.weave.reader.csv.CSVRecordsValue$$anon$1.hasNext(CSVReader.scala:58) at scala.collection.Iterator$class.toStream(Iterator.scala:1188) at com.mulesoft.weave.reader.csv.CSVRecordsValue$$anon$1.toStream(CSVReader.scala:56)
這是樣品CSV我使用
SpreadsheetKeyEmployee,Position,EffectiveDate,BonusPlan,Amount,Currency,IgnorePlanAssignment
1,18211,2016-05-01,BONUS_PLAN1,150,USD
2,18212,2016-05-01,BONUS_PLAN2,150,USD
3,18213,2016-05-01,BONUS_PLAN3,150,USD
4,18214,2016-05-01,BONUS_PLAN4,150,USD
我想我可能會做一些錯誤與讀者configuratuion(爲CSV)有一個類似的問題在論壇討論,但這不是幫助https://forums.mulesoft.com/questions/36378/dataweave-example-of-csv-to-json.html
它引發一個錯誤....異常堆棧是: 1. [錯誤:無法解析方法:java.lang.String.get(java.lang.String)[arglength = 1]] [附近:{... payload.get('contents')....}] ** – scorpion
我修改了表達式以直接使用有效載荷。這個想法是替換你的有效載荷中的所有\ r \ n,所以你需要根據你的用例修改MEL表達式。 – clare