嘿伙计们!
我有一个 JSON 文件,我想从中提取数据以在谷歌条形图中可视化数据。谷歌图表有特定的 JSON 格式,但我的文件中的数据是不同的 JSON 格式。我的问题是,是否可以将我的 JSON 文件转换为该格式,以便它操纵 google 可视化 api 的格式?
谷歌格式:
{
"cols": [
{"id":"","label":"Topping","pattern":"","type":"string"},
{"id":"","label":"Slices","pattern":"","type":"number"}
],
"rows": [
{"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]},
{"c":[{"v":"Onions","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Olives","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]}
]
}
JSON 文件格式:
{
"table.kot.educations": [
{"education":"Math","count":"8"},
{"education":"english","count":"15"},
{"education":"Management","count":"27"},
{"education":"Science","count":"14"},
{"education":"Social studies","count":"15"},
{"education":"Physics","count":"59"},
{"education":"Chemestry","count":"7"}
],
"table.user.educations":[
{"education":"Test i afdelingen med et meget meget meget meget langt navn","count":"2"},
{"education":"Test i IT-afdelingen","count":"3"},
{"education":"Test i PR-afdelingen","count":"2"}
],
"table.user.education.answer":[
{"education":"Math","answer":"N","count":"2"},
{"education":"Science","answer":"Y","count":"1"},
{"education":"Chemistry","answer":"N","count":"1"},
{"education":"Physics","answer":"Y","count":"1"}
]
}
谢谢 :)