如何将此 JSON 文件作为数据表打开?在将 JMP 中的这个 JSON 文件作为数据表打开时,我需要帮助: https://www.purpleair.com/data.json
我使用了 JMP 的 JSON 导入向导,但无法以我想要的方式打开文件。
我希望“字段”成为列标题,“数据”成为数据表中的行。 我提前感谢您的帮助。
数据表脚本Re: 如何将此 JSON 文件作为数据表打开?非常感谢@jthi !
Re: 如何将此 JSON 文件作为数据表打开?好的!
Re: 如何将此 JSON 文件作为数据表打开?很可能有更好的方法来处理这个问题,但这是一种可能的解决方案(由于 For Each 需要 JMP16):
Names Default To Here(1);
s = New HTTP Request(
url("https://www.purpleair.com/data.json"),
Method("GET"),
Headers({"Accept: application/json"})
) << Send;
aa_json = Associative Array(Parse JSON(s));
//aa_json << get keys;
//aa_json["fields"];
//Create collection table and columns
dt = New Table("json");
For Each({new_col}, aa_json["fields"],
dt << New Column(new_col);
);
Column(dt, "Label") << Data Type("Character"); //character columns must be set "manually"
//Fill rows
row_count = N Items(aa_json["data"]);
dt << Add Rows(row_count);
dt[0,0] = aa_json["data"];
Write(); //empty Write() to avoid printing all values to log