0
Hej guys!谷歌可視化api格式不正確json
我有一個JSON文件,我想從中提取數據以在谷歌條形圖中顯示數據。 Google圖表具有特定的JSON格式,但我的文件中的數據具有不同的JSON格式。 我的問題是,是否有可能將我的JSON文件轉換爲格式,以便它操縱谷歌可視化API的格式?
Google的格式:
{
"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"}
]
}
謝謝:)
感謝您的回答。我知道這兩種JSON格式都是有效的。我認爲使用Google可視化API創建的圖形只使用上面提到的JSON格式(Google格式)。我想將我的文件JSON格式轉換爲一個Google API可視化API使用的格式。有沒有簡單的方法從一種JSON格式轉換爲另一種? –