I have this section in my source code:
<file:inbound-endpoint connector-ref="fileConnector" path="C:/tmp/input" encoding="UTF-8" mimeType="application/json">
<file:filename-wildcard-filter pattern="*.json"/>
</file:inbound-endpoint>
<json:json-to-object-transformer returnClass="java.util.HashMap"/>
<logger level="INFO" message="#[message.payload]"/>
everything compile fine! but at execute throws the next exception: "Message: failed to transform from "json" to "java.util.HashMap" Code: MULE-ERROR-109"
Can anyone help me about this error?
The flow was as follows:
<file:inbound-endpoint connector-ref="fileConnector" path="C:/tmp/input" doc:name="File Input" responseTimeout="10000" encoding="UTF-8" mimeType="text/plain"> <file:filename-wildcard-filter pattern="*.json"/> </file:inbound-endpoint> <json:json-to-object-transformer returnClass="java.util.HashMap"doc:name="JSON to Object"/>`
The error was in the JSON file. The character encoding was not right and for this reason I was generating errors when trying to transform through
<json: json-to-object-transformer returnClass = "java.util.HashMap" doc: name = "JSON to Object" / >
after making reading the file with<file: inbound-endpoint>
attribute where I had defined as encoding = "UTF-8"
Solution
Change the character encoding of the JSON file to "UTF-8"
Knowledge Base:
If the exception stack is:
Message: Failed to transform from "json" to "java.util.HashMap" Code: MULE_ERROR-109
Exception stack is:
- Unexpected character ((code 65279 / 0xFEFF) '?'): Expected to valid value (number, string, array, object, 'true', 'false' or 'null') at [Source: java.io.InputStreamReader@2fba237; line 1, column 2 (org.codehaus.jackson.JsonParseException) org.codehaus.jackson.JsonParser: 1433 (null)
- Failed to transform from "json" to "java.util.HashMap (org.mule.api.transformer.TransformerException) org.mule.module.json.transformers.JsonToObject: 132 ( http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html )
Consider change the character encoding of the JSON file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.