-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Allow to configure return type in JSON array parsing #6558
Labels
Comments
sbordet
added
Enhancement
Sponsored
This issue affects a user with a commercial support agreement
labels
Jul 28, 2021
sbordet
added a commit
that referenced
this issue
Aug 2, 2021
Introduced `arrayConverter` in both JSON and AsyncJSON.Factory. Signed-off-by: Simone Bordet <[email protected]>
sbordet
added a commit
that referenced
this issue
Aug 3, 2021
Fixes #6558 - Allow configuring return type in JSON array parsing. Introduced `arrayConverter` in both JSON and AsyncJSON.Factory. Signed-off-by: Simone Bordet <[email protected]>
sbordet
added a commit
that referenced
this issue
Aug 3, 2021
Introduced `arrayConverter` in both JSON and AsyncJSON.Factory. Signed-off-by: Simone Bordet <[email protected]> (cherry picked from commit 342396c)
sbordet
added a commit
that referenced
this issue
Aug 4, 2021
Introduced `arrayConverter` in both JSON and AsyncJSON.Factory. Signed-off-by: Simone Bordet <[email protected]> (cherry picked from commit 342396c)
sbordet
added a commit
that referenced
this issue
Sep 27, 2021
Updated JSON implementation to keep backward compatibility by calling newArray(), now deprecated. Signed-off-by: Simone Bordet <[email protected]>
sbordet
added a commit
that referenced
this issue
Sep 27, 2021
Updated JSON implementation to keep backward compatibility by calling newArray(), now deprecated. Signed-off-by: Simone Bordet <[email protected]>
sbordet
added a commit
that referenced
this issue
Sep 27, 2021
Updated JSON implementation to keep backward compatibility by calling newArray(), now deprecated. Signed-off-by: Simone Bordet <[email protected]> (cherry picked from commit 1d542be)
sbordet
added a commit
that referenced
this issue
Sep 27, 2021
Updated JSON implementation to keep backward compatibility by calling newArray(), now deprecated. Signed-off-by: Simone Bordet <[email protected]> (cherry picked from commit 1d542be)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Target Jetty version(s)
9.4.x
Enhancement Description
Currently,
JSON.parse("[1]")
returns anObject[]
, whileAsyncJSON
returnsList<Object>
.This is a bit inconsistent, although there is no standard, so that many different implementation return different types (e.g. Jackson vs Gson vs Jetty), so applications need to be aware of these differences and "sniff" the type before casting.
Would be great if at least within Jetty we can make this consistent, so for example provide
AsyncJSON
of an option such asparseArrayAsList=true|false
so that it is consistent with theJSON
class.And perhaps the same to the JSON class.
For example, in CometD using the
AsyncJSONTransport
usesAsyncJSON
and therefore arrays are parsed as lists, whileWebSocketTransport
usesJSON
and so arrays are parsed as arrays.Trying to deserialize that JSON into an object whose class has a
setProperty(Object[] values)
, for example usingJSONPojoConvertor
, will work with one transport, but fail with the other, which is inconsistent.The text was updated successfully, but these errors were encountered: