@Override
    public int readI32() throws TException {
        readCurrentContext();

        final Class<?> fieldClass = getCurrentFieldClassIfIs(TEnum.class);
        if (fieldClass != null) {
            // Enum fields may be set by string, even though they represent integers.
            final JsonNode elem = getCurrentContext().getCurrentChild();
            if (elem.isInt() || Ints.tryParse(elem.asText()) != null) {
                return TypedParser.INTEGER.readFromJsonElement(elem);
            } else if (elem.isTextual()) {
                // All TEnum are enums
                @SuppressWarnings({ "unchecked", "rawtypes" })
                final TEnum tEnum = (TEnum) Enum.valueOf((Class<Enum>) fieldClass,
                                                         TypedParser.STRING.readFromJsonElement(elem));
                return tEnum.getValue();
            } else {
                throw new TTransportException("invalid value type for enum field: " + elem.getNodeType() +
                                              " (" + elem + ')');
            }
        } else {
            return readNameOrValue(TypedParser.INTEGER);
        }
    }
Helper shared by read{List/Set}End.
thrift/thrift0.13/src/main/java/com/linecorp/armeria/common/thrift/text/TTextProtocol.java