I have byte[]one that represents a UTF-8 encoded YAML string, and I want to deserialize it. Here is the general method that I use:
public static <T> T getInstanceFromBinary(final Class<T> clazz, final byte[] binary, final String encoding)
throws IOException {
final StringReader stringReader = new StringReader(new String(binary, encoding));
final String yamlString = stringReader.toString();
final boolean hasTab = yamlString.contains("\t");
final YamlReader reader = new YamlReader(stringReader);
final T clazzInstance = reader.read(clazz);
reader.close();
return clazzInstance;
}
and I get this exception:
Caused by: com.esotericsoftware.yamlbeans.tokenizer.Tokenizer$TokenizerException: Line 185, column 35: Tabs cannot be used for indentation.
at com.esotericsoftware.yamlbeans.tokenizer.Tokenizer.fetchMoreTokens(Tokenizer.java:313)
at com.esotericsoftware.yamlbeans.tokenizer.Tokenizer.peekNextToken(Tokenizer.java:120)
at com.esotericsoftware.yamlbeans.tokenizer.Tokenizer.peekNextTokenType(Tokenizer.java:125)
at com.esotericsoftware.yamlbeans.parser.Parser$20.produce(Parser.java:320)
at com.esotericsoftware.yamlbeans.parser.Parser.getNextEvent(Parser.java:80)
at com.esotericsoftware.yamlbeans.parser.Parser.peekNextEvent(Parser.java:91)
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:270)
at com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:152)
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:295)
... 38 more
The problem is that the decoded line does not seem to contain a tab character. Here's a screenshot from debugging that confirms this:

I also checked the source code of YAMLBeans, and found where this exception was thrown, although it did not give any light on why this was happening or how to solve this problem.
Thanks in advance for any ideas.
source
share