-
Notifications
You must be signed in to change notification settings - Fork 1.9k
preempt jsonlite message about keep_vec_names #4291
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
base: main
Are you sure you want to change the base?
Conversation
@r2evans Thanks for this proposal, but it isn't a complete fix as you're only taking into account first-level objects. ## with this PR
toJSON(list(a=5, b=list(b1 = c(b1 = "one"))))
#> Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite,
#> this option will not be supported, and named vectors will be translated into arrays
#> instead of objects. If you want JSON object output, please use a named list instead.
#> See ?toJSON.
#> {"a":5,"b":{"b1":{"b1":"one"}}} There's a bunch of historical behavior here, in fact the
Ideally, in the places where this error arises from internal Shiny code, we'd want to fix the warning. Feel free to open new issues with reproducible examples and we'll work to fix them. Beyond that, this behavior has been around long enough that I think jsonlite should either accept that |
That's a great point! I can update for that.
Certainly! And it's never been fully addressed. I believe it is not just
Technically, since my code is only for the internal
Besides #2673?
I don't wholly disagree. (Ironic that while you're telling me Doing what is suggested (dropping support, and therefore dropping all names in vectors) is likely the best thing to do, but wch's comment in that issue clearly communicated that that is not (or was not) the desired path for Frankly, I think there are a few paths from here:
Would you be more supportive of the third option above? The unstated fourth option of status quo is what I'm trying to avoid. Thoughts @gadenbuie ? |
It has been a long while since those comments and decisions were made. I opened jeroen/jsonlite#456 to discuss either moving forward on the promised plan or abandoning the message (my preference). I appreciate your offer to update the PR, but I don't think we should get into the business of recursively traversing data; especially not in a place that's on the critical path between server and client communication. I'd lean toward suppressing the message if jsonlite wants to keep the message indefinitely; otherwise I'd prefer to wait and see what jsonlite does. |
Prevent
jsonlite
's message aboutkeep_vec_names=
:If there are specific places where this is not working (and the use does not otherwise trigger the message), setting
fix_vec_names=FALSE
will bypass the additional step.I do find many calls to
jsonlite::toJSON(.)
in the package in addition to the (internal)toJSON(.)
, I'm not sure if that's intentional or if there can be some dis-ambiguation here. I'm happy to participate in that if it is beneficial.