Search before asking
Describe the bug
Hello folks,
As part of some work in upgrading from Jackson 2.x to 3.x (but I think it's unrelated in the end), I came upon the behaviour of TreeBuildingGenerator#writeNumber(String) which seems odd to me.
|
public JsonGenerator writeNumber(String encodedValue) { |
|
return writeString(encodedValue); |
|
} |
It writes the number (encoded as a string in input parameters) as a string in the underlying representation, especially it adds quotes around the input string. And it's then deserialized as a StringNode rather than a NumericNode.
This doesn't match what other implementations of JsonGenerator do, like WriterBasedJsonGenerator where the fact that it's a number is preserved: https://github.com/FasterXML/jackson-core/blob/0406a51a186125a451e3353ee1824f9a0407b152/src/main/java/tools/jackson/core/json/WriterBasedJsonGenerator.java#L907-L918
Am I missing something ; is this the intended behaviour?
Version Information
3.0.3
Reproduction
None yet but I can come up with something if needed.
Expected behavior
Write numbers as numbers.
Additional context
No response
Search before asking
Describe the bug
Hello folks,
As part of some work in upgrading from Jackson 2.x to 3.x (but I think it's unrelated in the end), I came upon the behaviour of
TreeBuildingGenerator#writeNumber(String)which seems odd to me.jackson-databind/src/main/java/tools/jackson/databind/node/TreeBuildingGenerator.java
Lines 407 to 409 in f946c3d
It writes the number (encoded as a string in input parameters) as a string in the underlying representation, especially it adds quotes around the input string. And it's then deserialized as a
StringNoderather than aNumericNode.This doesn't match what other implementations of
JsonGeneratordo, likeWriterBasedJsonGeneratorwhere the fact that it's a number is preserved: https://github.com/FasterXML/jackson-core/blob/0406a51a186125a451e3353ee1824f9a0407b152/src/main/java/tools/jackson/core/json/WriterBasedJsonGenerator.java#L907-L918Am I missing something ; is this the intended behaviour?
Version Information
3.0.3
Reproduction
None yet but I can come up with something if needed.
Expected behavior
Write numbers as numbers.
Additional context
No response