mmmartins Posted May 28, 2019 Share Posted May 28, 2019 When loading a Json Data Source with the character ã the error occurs:net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x6eHere is an example of JaspeReport and Json:{"a": [ {"b": { "val": "vãl1"}}, {"b": { "val": "vãl2" }}]}<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Teste" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ab27e09a-5076-4a1f-9721-c717402d3f12"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test_Json"/> <parameter name="jsonString" class="java.lang.String"> <defaultValueExpression><![CDATA["{"a": [ {"b": { "val": "val3"}}, {"b": { "val": "val2" }}]}"]]></defaultValueExpression> </parameter> <parameter name="JSON_INPUT_STREAM" class="java.io.InputStream"> <defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{jsonString}.getBytes("UTF-8"))]]></defaultValueExpression> </parameter> <queryString language="json"> <![CDATA[a.b]]> </queryString> <field name="value" class="java.lang.String"> <fieldDescription><![CDATA[val]]></fieldDescription> </field> <columnHeader> <band height="31" splitType="Stretch"> <staticText> <reportElement x="150" y="0" width="100" height="30" uuid="b33a123d-8987-4da4-b21b-1f9ccc50e92d"/> <text><![CDATA[value]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <textField> <reportElement x="150" y="0" width="100" height="30" uuid="14c51219-5ce2-47ce-abb9-71bc11a6f28c"/> <textFieldExpression><![CDATA[$F{value}]]></textFieldExpression> </textField> </band> </detail></jasperReport> With json below it works ok:{"a": [ {"b": { "val": "val1"}}, {"b": { "val": "val2" }}]}The character and others with accentuation are very common in the Portuguese language. Link to comment Share on other sites More sharing options...
narcism Posted May 31, 2019 Share Posted May 31, 2019 It looks like you have an encoding issue. If your data comes from a JSON file you need to make sure it is UTF-8 encoded. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now