FasterXML / FasterXML/jackson-dataformats-binary

Honor READ_ENUMS_USING_TO_STRING feature when deserializing

Open
#397 3 comments 0 reactions 0 assignees View on GitHub
protobuf
Dominant language
Java
Stars
347
Forks
156
Avg merge
3d 3h
Merged PRs (30d)
22

Description

Currently the ProtobufParser uses a condition (isStdEnum) to know it we need to deserialize using the index form or string form.

case ENUM:
// 12-Feb-2015, tatu: Can expose as index (int) or name, but internally encoded as VInt.
// So for now, expose as is; may add a feature to choose later on.
// But! May or may not be directly mapped; may need to translate
{
int ix = _decodeLength();
if (_currentField.isStdEnum) {
_numberInt = ix;
_numTypesValid = NR_INT;
type = JsonToken.VALUE_NUMBER_INT;
} else {
// Could translate to better id, but for now let databind
// handle that part
String enumStr = _currentField.findEnumByIndex(ix);
if (enumStr == null) {
_reportErrorF("Unknown id %d (for enum field %s)", ix, _currentField.name);
}
type = JsonToken.VALUE_STRING;
_textBuffer.resetWithString(enumStr);
}
}
break;

We could honor the READ_ENUMS_USING_TO_STRING feature so we return the string form when this feature is enabled.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.