playframework / playframework/play-json

support jackson-core fast number parsing

Open
#835 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
375
Forks
140
Avg merge
1d 5h
Merged PRs (30d)
28

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating play-json's BigDecimalParser and its Jackson JsonFactory integration, then review Jackson's USE_FAST_DOUBLE_PARSER, USE_FAST_DOUBLE_WRITER, USE_FAST_BIG_NUMBER_PARSER, and StreamReadConstraints. Done means assessing opt-in fast parsing and writing while preserving play-json's existing number-length checks and accounting for Jackson 2.15 constraints.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.