-
Notifications
You must be signed in to change notification settings - Fork 255
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
Nested JSON #372
Comments
I don't understand what you mean. There's no difference between flat JSON and multi-layered JSON, in my opinion. An example may help to understand. |
I was about to ask the same question (I think) so I decided to comment here. In my case, the application requires that the I checked the code and it seems that there is not way to configure that. Maybe adding a way to set custom settings for the default filters? |
Closing due to inactivity As a note, |
@schloerke I just stumbled upon this issue and I think I'm having the same problem. Here's what I want to be able to do: #* @param bar
#* @post /foo
foo <- function(bar) {
bar
} and be able to make requests to that endpoint like this: POST(
"<< some url >>/foo"
body = list(
baz = list(
bar = "abc",
qux = 123
) %>% toJSON()
)
) but it appears (at least AFAICT) that in order to be able to use nesting like that, I'll need to parse the JSON myself. Is there a best practice for how to deal with nested json like this? I'd almost like to be able to do something like |
Plumber will parse your json input and do a named argument matching only for the top level elements (non nested) via an R do.call. More detailed It does a do.call with your handler function Line 84 in 20c7d9f
json parser : Line 383 in 28bc58c
safeFromJson method : https://github.com/rstudio/plumber/blob/master/R/json.R If this is not enough, you could write your own parser as it is relatively easy to extend. https://www.rplumber.io/reference/register_parser.html #* @param baz
#* @post /foo
function(baz) {
baz$bar
} |
@meztez Aha, gotcha with the updated comment. Thanks! |
Hello,
I started with Plumber today and it is working great. When the JSON is flat, it works exactly as expected.
How does Plumber deal with JSON that is nested and multi-layered? How would I craft the function in this manner?
Am I to understand that I have to flatten the structure before i send it over?
Thanks
The text was updated successfully, but these errors were encountered: