: Birçok çift olduğundaBen anahtar değeri öğeleri bir dizi, böyle bir şey olabilir yapmak için ortak bir yol saklamak istediğiniz
// the JSON data may store several data types, not just key value lists,
// but, must be able to identify some data as a key value list
// --> more "common" way to store a key value array
{
[
{"key": "slide0001.html", "value": "Looking Ahead"},
{"key": "slide0008.html", "value": "Forecast"},
{"key": "slide0021.html", "value": "Summary"},
// another THOUSANDS KEY VALUE PAIRS
// ...
],
"otherdata" : { "one": "1", "two": "2", "three": "3" }
}
Ama/öğeleri, dizi uzunluğu men olursa, ve ben bir kompakt yol istiyorsanız, bu bir örnek olabilir: Ayrıca
// --> (1) a "compact" way to store a key value array
{
[
{"slide0001.html", "Looking Ahead"},
{"slide0008.html", "Forecast"},
{"slide0021.html", "Summary"},
// another THOUSANDS KEY VALUE PAIRS
// ...
],
"otherdata" : { "one": "1", "two": "2", "three": "3" }
}
, ben bir keyvalue dizi olarak verileri çünkü tanımlamak için bir yol istiyorum, isteyebilirsiniz diğer verileri aynı JSON dosyasında saklamak için Eğer başka bir yol var mı, sen öneriyorsun sen şeyi, hangi birini ne
// --> (2) a "compact" way to store a key value array
{
"keyvaluelist":
[
{"slide0001.html", "Looking Ahead"},
{"slide0008.html", "Forecast"},
{"slide0021.html", "Summary"},
// another THOUSANDS KEY VALUE PAIRS
// ...
],
"otherdata" : { "one": "1", "two": "2", "three": "3" }
}
// --> (3) a "compact" way to store a key value array
{
"mylist":
{
"type": "keyvaluearray",
"data":
[
{"slide0001.html", "Looking Ahead"},
{"slide0008.html", "Forecast"},
{"slide0021.html", "Summary"},
// another THOUSANDS KEY VALUE PAIRS
// ...
]
},
"otherdata" : { "one": "1", "two": "2", "three": "3" }
}
: Ben bu örnekleri var mı? Teşekkürler.
UPDATE 1: Geçersiz kodu kaldırın. JavaScript => JSON
GÜNCELLEME 2: Ekle olmayan anahtar değeri verileri
GÜNCELLEME 3: Her anahtar değeri çiftinde "{" ve "}" için Değiştir "[" ve "]"
Kodunuzda tek bir JSON satırı yok. Sadece JavaScript nesneleri. –
@Felix Kling. Teşekkürler. JSon – umlcat
yerine JS gibi geçersiz kodları kaldırıyorum, hala JSON değil. JSON'da, her anahtarın (ve dizenin) çift tırnak içinde olması ve 'param =' gibi bir şey olmaması gerekir. –