I have a CFC, which returns a struct, converted into JSON format. This is
the method declaration:
The output looks just fine, but it’s not in UTF-8.
I have tried this:
SetEncoding(“url”, “utf-8”); SetEncoding(“form”, “utf-8”);
And I saved the .cfc file as UTF-8 with BOM.
I want to use this as the datasource for a Jasper report, but I always get
this error message:
Invalid UTF-8 middle byte 0x74 at [Source: java.io.ByteArrayInputStream@6c2071a7; line: 1, column: 745]
The JSON data contains german umlauts. First one of them is at this
position: “line: 1, column: 745”.
The error occurs when creating the datasource. InputStream is not in UTF-8.
jsonUrl = getParam(‘JSON_URL’, ReportParamArray); inputStream = CreateObject(“java”, “java.net.URL”).init(jsonUrl).openConnection().getInputStream(); jasperPrint = jasFillManager.fillReport(jasReport, parameters, CreateObject(“java”, “net.sf.jasperreports.engine.data.JsonDataSource”).init(inputStream));
How can I ensure, that the CFC returns valid UTF-8 content?