[JAVA] Unexpected JSON event 'VALUE_TRUE' instead of '[KEY_NAME, VALUE_STRING]'

I was able to reproduce it from the pastebin output (thanks for providing it!) and decoding it as follows:

InputStream is = this.getClass().getResourceAsStream("discuss-295740.json");
JsonParser parser = mapper.jsonProvider().createParser(is);
try {
    JsonpDeserializer.of(GetIndexTemplateResponse.class).deserialize(parser, mapper);
} catch(UnexpectedJsonEventException e) {
    JsonLocation loc = e.getLocation();
    fail(loc.getLineNumber() + ":" + loc.getColumnNumber());
}

The result is 419:29, which points to:

"mappings" : {
   ...
   "dynamic" : true, // <-- line 419
   "dynamic_templates" : [ ],
   ...

This is an incarnation of this isssue on read rather than on write: Serialize DynamicMapping values as booleans instead of string · Issue #139 · elastic/elasticsearch-java · GitHub

Please watch that issue for resolution.

2 Likes