I am new to R . I am supposed to expose rest service using R , So i found plumber to expose rest service using R , I Successfully implemented plumber in R , but in response i am receiving a json array like below
[{"name":"Rajesh","age":"10"}]
how to remove the array from the above response
my expected output is like below
{"name":"Rajesh","age":"10"}
Code
library(plumber)
r <- plumb("MyFile.R")
r$run(port=8000)
My File .R is mentioned below
#* @post /sum
addTwo <- function(){
name<-c("Rajesh")
age<-c("10")
df<-data.frame(name,age)
return(df)
}
library(jsonlite)
df <- jsonlite::toJSON(data.frame(name, age, auto_unbox=TRUE))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With