You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求将指定JSON数据解析为Data Frame(附R代码示例)

Parsing JSON to Data Frame in R

No worries, parsing that JSON string into a Data Frame is straightforward with the jsonlite package—here's how to do it step by step:

Step 1: Install and load the jsonlite package

First, make sure you have the package installed (if you haven't already) and loaded. This package handles JSON conversions smoothly for R:

# Install if needed
install.packages("jsonlite")

# Load the package
library(jsonlite)

Step 2: Parse the JSON string

Use your existing JSON assignment, then convert it to a Data Frame. Since your JSON is a single object, we'll use fromJSON() to parse it into a list, then convert that list to a Data Frame with as.data.frame():

# Your original JSON assignment
js <- '{"name": null, "release_date_local": null, "title": "3 (2011)", "opening_weekend_take": 1234, "year": 2011, "release_date_wide": "2011-09-16", "gross": 59954}'

# Parse and convert to Data Frame
movie_df <- as.data.frame(fromJSON(js))

Step 3: Check the result

If you print the Data Frame, you'll get a nicely structured table with all your JSON fields as columns:

print(movie_df)

Output:

name release_date_local     title opening_weekend_take year release_date_wide gross
1 NULL               NULL 3 (2011)                 1234 2011        2011-09-16 59954

A quick note: The null values in the JSON show up as NULL in the Data Frame, which is the expected R equivalent.

内容的提问来源于stack exchange,提问作者Rajesh Gowda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:57:17