Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从这个 JSON 字符串中获取值:{ "item": [ { "value": 142 } , { "value": 200 } ] }
{ "item": [ { "value": 142 } , { "value": 200 } ] }
代码:
library(rjson) item <- list(item=c(value= 142,value=200)) toJSON(item)
我有:
> toJSON(item) [1] "{\"item\":{\"value\":142,\"value\":200}}"
如何从 R 中的 json 字符串中获取值?
文档中的讨论I()及其作用RJSONIO,但这就是您要寻找的...
I()
RJSONIO
library("RJSONIO") item <- list(item=I(list(list(value= 142),list(value=200)))) > toJSON(item) [1] "{\n \"item\": [\n {\n \"value\": 142 \n},\n{\n \"value\": 200 \n} \n] \n}"