Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json.parse fails for strings > 5000000 in length #1054

Open
RiteshBM opened this issue Jun 26, 2024 · 4 comments
Open

Json.parse fails for strings > 5000000 in length #1054

RiteshBM opened this issue Jun 26, 2024 · 4 comments

Comments

@RiteshBM
Copy link

RiteshBM commented Jun 26, 2024

Play JSON Version (2.5.x / etc)

2.9.4

API (Scala / Java / Neither / Both)

Scala

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

MacOS 14.3 M1

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

Amazon Cornetto Java 17.0.7

Library Dependencies

com.fasterxml.jackson.core:jackson-databind "2.15.0"
com.fasterxml.jackson.core:jackson-core "2.15.0"
com.fasterxml.jackson.core:jackson-annotations "2.15.0"
com.fasterxml.jackson.module:jackson-module-scala_2.12 "2.15.0"

Expected Behavior

  1. Parsing a JSON String with length > 5000000
  2. Returns a JsValue Object

Actual Behavior

throws an exception: com.fasterxml.jackson.core.exc.StreamConstraintsException: String length (5043551) exceeds the maximum length (5000000)

Jackson version: 2.15.0

Reproducible Test Case

val largeString = "a" * 20 * 1000000
val largeJsonString = s"""{ "key": "$largeString" }"""

Related Issues

FasterXML/jackson-core#1001

I've used Json.parse in multiple places. I think Play doesn't expose a way to configure this limit globally. Will I have to create a custom ObjectMapper everywhere ?

@mkurz
Copy link
Member

mkurz commented Jun 27, 2024

Will take a look at this in the course of upgrading jackson.

@pjfanning
Copy link
Contributor

@RiteshBM Play does not support Jackson 2.15 or above. Jackson 2.15 introduced StreamReadConstraints and Play has not yet implemented anything to allow users with very large JSON docs to override the default Jackson settings.

Stick with Jackson 2.14.

@RiteshBM
Copy link
Author

@pjfanning Does it mean I can't use Play without bypassing this limit if other packages require jackson > 2.14.

@pjfanning
Copy link
Contributor

@RiteshBM Play does not support Jackson 2.15 or above. Jackson 2.15 introduced StreamReadConstraints and Play has not yet implemented anything to allow users with very large JSON docs to override the default Jackson settings.

Stick with Jackson 2.14.

Try calling this method to override the StreamReadConstraints.

https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/latest/com/fasterxml/jackson/core/StreamReadConstraints.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants