0

いくつかの簡単なキーワードを含むJSONファイルを解析しようとしています。関数が実行されていません。jQuery .getJSONのドキュメントを見ると、最も可能性の高い説明は構文エラーであることがわかりました。私は自分のコードをかなり徹底的に調べましたが、今日はJSONしか学びませんでした。誰かが私を助けることができますか?申し訳ありませんが、データが多いことは承知しています。

JavaScriptコード:

$(document).ready(function() {
$.getJSON('edit/key.json', function(data2) {
    console.log(data2);
    //more code
});

});

JSONコード:

{
"RAM": [
    {"term" : "ram"},
    {"term" : "memory"},
    {"term" : "access"},
    {"term" : "random"},
    {"term" : "component"},
    {"term" : "multi-tasking"},
    {"term" : "multi"},
    {"term" : "tasking"},
    {"term" : "gigabyte"},
    {"term" : "temporary"}
],
"Graphics Card": [
    {"term" : "component"},
    {"term" : "graphic"},
    {"term" : "graphics card"},
    {"term" : "processing"},
    {"term" : "processors"},
    {"term" : "unit"},
    {"term" : "card"},
    {"term" : "3D"},
    {"term" : "image"},
    {"term" : "media"},
    {"term" : "gaming"},
    {"term" : "game"},
    {"term" : "nvidia"},
    {"term" : "amd"},
    {"term" : "chip"},
    {"term" : "clock"},
    {"term" : "speed"},
    {"term" : "GPU"},
    {"term" : "video"},
    {"term" : "DVI"},
    {"term" : "DisplayPort"},
    {"term" : "HDMI"}
],
"Ports": [
    {"term" : "port"},
    {"term" : "interface"},
    {"term" : "external"},
    {"term" : "USB"},
    {"term" : "devices"},
    {"term" : "3.0"},
    {"term" : "2.0"},
    {"term" : "VGA"},
    {"term" : "DVI"},
    {"term" : "HDMI"},
    {"term" : "display"},
    {"term" : "port"},
    {"term" : "memory"},
    {"term" : "card"},
    {"term" : "SD"},
    {"term" : "stick"},
    {"term" : "ethernet"},
    {"term" : "input"},
    {"term" : "output"},
],
"CPU": [
    {"term" : "cpu"},
    {"term" : "central"},
    {"term" : "processing"},
    {"term" : "unit"},
    {"term" : "computing"},
    {"term" : "compute"},
    {"term" : "intel"},
    {"term" : "AMD"},
    {"term" : "processors"},
    {"term" : "desktop"},
    {"term" : "laptop"},
    {"term" : "i3"},
    {"term" : "i5"},
    {"term" : "i7"},
    {"term" : "core"},
    {"term" : "turbo"},
    {"term" : "boost"},
    {"term" : "gaming"},
    {"term" : "media"},
    {"term" : "overclocked"},
    {"term" : "clock"},
    {"term" : "speed"}
],
"Hard Drive": [
    {"term" : "store"},
    {"term" : "data"},
    {"term" : "hard"},
    {"term" : "drive"},
    {"term" : "video"},
    {"term" : "music"},
    {"term" : "picture"},
    {"term" : "document"},
    {"term" : "media"},
    {"term" : "processor"},
    {"term" : "gigabyte"},
    {"term" : "terabyte"},
    {"term" : "rpm"},
    {"term" : "cache"}
],
"Operating System": [
    {"term" : "operating"},
    {"term" : "system"},
    {"term" : "os"},
    {"term" : "device"},
    {"term" : "windows"},
    {"term" : "mac"},
    {"term" : "linux"},
    {"term" : "ubuntu"},
    {"term" : "chrome"},
    {"term" : "xp"},
    {"term" : "vista"},
    {"term" : "7"},
    {"term" : "8"},
    {"term" : "home"},
    {"term" : "premium"},
    {"term" : "professional"},
    {"term" : "ultimate"},
]}
4

1 に答える 1

2

確かに、いくつかの構文エラーがあります。

ポート配列に余分なコンマがあります。{"term": "output"}の後にコンマがありますが、最後の要素であってはなりません。

配列「オペレーティングシステム」の最後の要素でも同じことが起こります。最後の要素{"term"、 "ultimate"}の後には、カンマを入れないでください。

これは、正しく解析する必要がある正しいコードです。

{
"RAM": [
    {"term" : "ram"},
    {"term" : "memory"},
    {"term" : "access"},
    {"term" : "random"},
    {"term" : "component"},
    {"term" : "multi-tasking"},
    {"term" : "multi"},
    {"term" : "tasking"},
    {"term" : "gigabyte"},
    {"term" : "temporary"}
],
"Graphics Card": [
    {"term" : "component"},
    {"term" : "graphic"},
    {"term" : "graphics card"},
    {"term" : "processing"},
    {"term" : "processors"},
    {"term" : "unit"},
    {"term" : "card"},
    {"term" : "3D"},
    {"term" : "image"},
    {"term" : "media"},
    {"term" : "gaming"},
    {"term" : "game"},
    {"term" : "nvidia"},
    {"term" : "amd"},
    {"term" : "chip"},
    {"term" : "clock"},
    {"term" : "speed"},
    {"term" : "GPU"},
    {"term" : "video"},
    {"term" : "DVI"},
    {"term" : "DisplayPort"},
    {"term" : "HDMI"}
],
"Ports": [
    {"term" : "port"},
    {"term" : "interface"},
    {"term" : "external"},
    {"term" : "USB"},
    {"term" : "devices"},
    {"term" : "3.0"},
    {"term" : "2.0"},
    {"term" : "VGA"},
    {"term" : "DVI"},
    {"term" : "HDMI"},
    {"term" : "display"},
    {"term" : "port"},
    {"term" : "memory"},
    {"term" : "card"},
    {"term" : "SD"},
    {"term" : "stick"},
    {"term" : "ethernet"},
    {"term" : "input"},
    {"term" : "output"}
],
"CPU": [
    {"term" : "cpu"},
    {"term" : "central"},
    {"term" : "processing"},
    {"term" : "unit"},
    {"term" : "computing"},
    {"term" : "compute"},
    {"term" : "intel"},
    {"term" : "AMD"},
    {"term" : "processors"},
    {"term" : "desktop"},
    {"term" : "laptop"},
    {"term" : "i3"},
    {"term" : "i5"},
    {"term" : "i7"},
    {"term" : "core"},
    {"term" : "turbo"},
    {"term" : "boost"},
    {"term" : "gaming"},
    {"term" : "media"},
    {"term" : "overclocked"},
    {"term" : "clock"},
    {"term" : "speed"}
],
"Hard Drive": [
    {"term" : "store"},
    {"term" : "data"},
    {"term" : "hard"},
    {"term" : "drive"},
    {"term" : "video"},
    {"term" : "music"},
    {"term" : "picture"},
    {"term" : "document"},
    {"term" : "media"},
    {"term" : "processor"},
    {"term" : "gigabyte"},
    {"term" : "terabyte"},
    {"term" : "rpm"},
    {"term" : "cache"}
],
"Operating System": [
    {"term" : "operating"},
    {"term" : "system"},
    {"term" : "os"},
    {"term" : "device"},
    {"term" : "windows"},
    {"term" : "mac"},
    {"term" : "linux"},
    {"term" : "ubuntu"},
    {"term" : "chrome"},
    {"term" : "xp"},
    {"term" : "vista"},
    {"term" : "7"},
    {"term" : "8"},
    {"term" : "home"},
    {"term" : "premium"},
    {"term" : "professional"},
    {"term" : "ultimate"}
]}
于 2012-09-10T00:22:34.453 に答える