-
-
Couldn't load subscription status.
- Fork 149
Closed
Description
Hello, currently, we're decoding Simple values from Major type (7) as VALUE_NUMBER_INT Token, where it's better to be decoded using a special type (I agree and assume VALUE_EMBEDDED_OBJECT would work and no need for additional type as commented)
jackson-dataformats-binary/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java
Lines 3679 to 3705 in 63fdc54
| public JsonToken _decodeSimpleValue(int lowBits, int ch) throws IOException { | |
| if (lowBits > 24) { | |
| _invalidToken(ch); | |
| } | |
| if (lowBits < 24) { | |
| _numberInt = lowBits; | |
| } else { // need another byte | |
| if (_inputPtr >= _inputEnd) { | |
| loadMoreGuaranteed(); | |
| } | |
| _numberInt = _inputBuffer[_inputPtr++] & 0xFF; | |
| // As per CBOR spec, values below 32 not allowed to avoid | |
| // confusion (as well as guarantee uniqueness of encoding) | |
| if (_numberInt < 32) { | |
| throw _constructError("Invalid second byte for simple value: 0x" | |
| +Integer.toHexString(_numberInt)+" (only values 0x20 - 0xFF allowed)"); | |
| } | |
| } | |
| // 25-Nov-2020, tatu: Although ideally we should report these | |
| // as `JsonToken.VALUE_EMBEDDED_OBJECT`, due to late addition | |
| // of handling in 2.12, simple value in 2.12 will be reported | |
| // as simple ints. | |
| _numTypesValid = NR_INT; | |
| return (JsonToken.VALUE_NUMBER_INT); | |
| } |
I'm writing this issue so we track it, where we can introduce that change with a feature flag default to false for earlier versions, and true for 3.0 onward.
cowtowncoder