title: Write JSON file as UTF-8 encoded
body: <p>I am writing a method that writes some JSON to a file, which works fine. However, although I have set the output to be UTF-8, <a href="http://www.oxygenxml.com/download.html" rel="nofollow">Oxygen</a> fails to read a pound and euro sign.</p>
  
  <p>Java code:</p>
  
  <pre><code>Path logFile = Paths.get(this.output_folder + "/" + file.getName().split("\\.")[0] + ".json");
  try (BufferedWriter writer = Files.newBufferedWriter(logFile, StandardCharsets.UTF_8)) {
      File fileDir = new File("test.json");
      Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileDir), "UTF8"));
      ObjectMapper mapper = new ObjectMapper();
      writer.write(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(all_questions));
  }
  </code></pre>
  
  <p>"all_questions" is an arraylist of Question objects, which is being printed as a formatted piece of JSON by an ObjectMapper.</p>
  
  <p>Some sample JSON with the pound sign looks like this:</p>
  
  <pre><code>{
        "name" : "RegExRule",
        "field" : "Q039_4",
        "rules" : [ ],
        "fileName" : "s1rules_england_en.xml",
        "error" : null,
        "pattern_match" : {
          "$record.ApplicationData.SiteVisit.VisitContactDetails.ContactOther.PersonName.PersonGivenName" : "^[\\u0000-\\u005F\\u0061-\\u007B\\u007d-\\u007f£€]*$"
        }
  }
  </code></pre>
  
  <p>However, that is displayed in notepad++. In Oxygen, it is displayed as follows:</p>
  
  <pre><code>"pattern_match" : {
          "$record.ApplicationData.SiteVisit.VisitContactDetails.ContactOther.PersonName.PersonGivenName" : "^[\\u0000-\\u005F\\u0061-\\u007B\\u007d-\\u007fÂ£â‚¬]*$"
   }
  </code></pre>