How to send json response using plumber R

前端 未结 2 1723
执念已碎
执念已碎 2020-12-21 00:08

I need to send response from R using plumber package in below format

{
  \"status\": \"SUCCESS\",
  \"code\": \"200\",
  \"output\": {
    \"studentid\": \"1         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-21 00:34

    Just remove the toJSON() wrapper. Plumber already does JSON serialisation so you are doing it twice by adding a toJSON function.

    This should work.

     addTwo <- function(){
      x <- list(status = "SUCCESS", code = "200",output = list(studentid = "1001", name = "Kevin"))
      return (x)
    }
    

提交回复
热议问题