Mule 3.7.3 - Dataveawe Message Transformer Encoding Wrongly
<p>I am using mule to transform some webservice responses on my project, and currently i am using DataWeave message transformer. </p>

<p>JSON that i should transform :</p>

<pre><code>{
  "odata.metadata": "http://mchwtatmsdb/Across/CrossTank/api/v1/$metadata#Translations",
  "value": [
    {
      "SourceSentence": {
        "Id": 2750901,
        "Text": "Refrigerator:",
        "Language": 1033
      },
      "TargetSentence": {
        "Id": 2750902,
        "Text": "Kühlschrank:",
        "Language": 1031
      },
      "Id": 2264817,
      "Similarity": 100,
      "CreationDate": "2009-02-25T12:56:15",
      "Creator": "41e8d49d-0de7-4a96-a220-af96d94fe4b0",
      "ModificationDate": "2009-02-25T12:56:15",
      "Modificator": "00000000-0000-0000-0000-000000000000",
      "State": "SmartInserted",
      "Note": ""
    },
    {
      "SourceSentence": {
        "Id": 2750906,
        "Text": "Refrigerator*",
        "Language": 1033
      },
      "TargetSentence": {
        "Id": 2750907,
        "Text": "Kühlschrank*",
        "Language": 1031
      },
      "Id": 2264822,
      "Similarity": 100,
      "CreationDate": "2009-02-25T12:55:46",
      "Creator": "41e8d49d-0de7-4a96-a220-af96d94fe4b0",
      "ModificationDate": "2009-02-25T12:55:46",
      "Modificator": "00000000-0000-0000-0000-000000000000",
      "State": "SmartInserted",
      "Note": ""
    }
  ]
}
</code></pre>

<p>I am basically using transformer, define metadatas respective to json files that is included in the project.</p>

<p>So transformer part is so simple :</p>

<pre><code>&lt;dw:set-payload&gt;&lt;![CDATA[%dw 1.0
%output application/json
---
{
    "odata.metadata": payload."odata.metadata",
    value: payload.value map ((value , indexOfValue) -&gt; {
        SourceSentence: {
            Id: value.SourceSentence.Id,
            Text: value.SourceSentence.Text as :string,
            Language: value.SourceSentence.Language
        },
        TargetSentence: {
            Id: value.TargetSentence.Id,
            Text: value.TargetSentence.Text,
            Language: value.TargetSentence.Language
        },
        Similarity: value.Similarity
    })
}]]&gt;&lt;/dw:set-payload&gt;
</code></pre>

<p>Transformation runs in expected way and it gets the necessary fields that i've set in dataweave transformer, after transformer implemented on json string, it changes the encoding somehow, and output doesn't show special characters. Such as: </p>

<pre><code>{
  "odata.metadata": "http://mchwtatmsdb/Across/CrossTank/api/v1/$metadata#Translations",
  "value": [
    {
      "SourceSentence": {
        "Id": 2750901,
        "Text": "Refrigerator:",
        "Language": 1033
      },
      "TargetSentence": {
        "Id": 2750902,
        "Text": "K252hlschrank:",
        "Language": 1031
      },
      "Similarity": 100
    },
    {
      "SourceSentence": {
        "Id": 2750906,
        "Text": "Refrigerator*",
        "Language": 1033
      },
      "TargetSentence": {
        "Id": 2750907,
        "Text": "K252hlschrank*",
        "Language": 1031
      },
      "Similarity": 100
    }
  ]
}
</code></pre>

<p>"Text": "K252hlschrank*" part of the string is showing "ü" character as "252" i tried to run project both on the Windows an Linux environment. On linux, character is shown as "\u00" so i think this is somehow related OS problem. I've tried several things to fix the problem.</p>

<p>Tried to change project properties, set encoding to "UTF-8". It didn't work.</p>

<p>Tried to change run configuration, set encoding to "UTF-8". It didn't work.</p>

<p>Tried to give -Dfile.encoding="UTF-8" parameter into run parameters of Java, again it didn't work.</p>

<p>What is source of this problem, are transformers direclty using operating system's encoding ? Because without transformation, main json file represented as "ü", no encoding problem.</p>