Skip to content

support jackson-core fast number parsing #835

@pjfanning

Description

@pjfanning

Jackson 2.14's JsonFactory supports these features.

  • StreamReadFeature.USE_FAST_DOUBLE_PARSER
  • StreamWriteFeature.USE_FAST_DOUBLE_WRITER

play-json's BigDecimalParser may also benefit from using jackson-core's BigDecimalParser - you should keep the number length check that play-json has but the parsing of the string can benefit from jackson-core's BigDecimalParser which has special code to speed up parsing of very long numbers.

Just thought I'd raise awareness of these features of jackson-core. With the StreamReadFeature and StreamWriteFeature, you would probably want to make those opt-in - that play-json should probably not use them by default.

Jackson 2.15.0-rc1 is out today (Mar 18, 2023). It has an additional feature - StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER

You can make the limits effectively unlimited by creating a JsonFactory that overrides the default StreamReadConstraints.
An example that increases the max number len:

   val jsonFactory = JsonFactory.builder()
     .streamReadConstraints(StreamReadConstraints.builder().maxNumberLength(Integer.MAX_INTEGER).build())
     .build()

If you do plan to upgrade to use Jackson 2.15, you will need to consider how to integrate Jackson's StreamReadConstraints (particularly the number len check) with play-json's pre-existing support for checking the len of BigDecimal/BigInteger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions