简体   繁体   中英

while parsing YML to POJO getting exception Invalid UTF-8 start byte 0x80 (at char #158, byte #-1)

I am trying to parse yml file into java object while parsing yml file with object mapper getting below exception.

Exception in thread "main" com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException: java.io.CharConversionException: Invalid UTF-8 start byte 0x80 (at char #158, byte #-1) at [Source: (File); line: 1, column: 1] at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:361) at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4620) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4469) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3299)

my java code

ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
XmlConverterProp prop = objectMapper.readValue(configFile, XmlConverterProp.class);

yml file

dateFormat: "MM/dd/yyyy=Billing_Date"
lineItemRowNodeName: row
lineItemsNodeName: Mode_Items
removeValueChars: "Net_Amount=$,Unit_Price=Rs.,Item_Amount=€,Gross_Amount=$"
requiredHeaderTags: "cc_BatchDetails,Invoice_Number,Invoice_Date,PO_Number,Document_Type,Vendor_Name,Tax_Amount,Net_Amount,Invoice_Amount,Currency,Gross_Amount,cc_ProfileName,Remit_To_Address_1"
requiredLineTags: "Item_Code,Item_Description,Quantity,Unit_Price,Item_Amount"

The problematic character is the euro sign. Your input is not encoded as UTF-8, since the euro sign is encoded as 0x80 . This corresponds to IEC_8859-15 (Latin-9) or Windows-1252 .

YAML requires the input to be one of the UTF-encodings (8, 16 or 32), the most common being UTF-8. You need to encode your YAML file in UTF-8 or one of the others for it to properly load. All code editors provide a way to do this, most have the option in the bottom status bar.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM