次のようなjsonファイルを使用する必要があります。
({"weather":{"city":"Paris", "country":"France"}})
JsonStore を次のように記述します。
root : "weather",
fields : ['city', 'country']
次のようにアクセスできません:
myStore.on('load', function(store, records, options) {
alert(records[0].get('city'));
}
しかし、jsonファイルにブラケットがないため、どうすればそれらにアクセスできますか
別のケースは、次のようなものにアクセスしたい場合です:
({"data":{"weather":[{ "city" : "Paris", "country" : [{"value" : "France"}] }]}})
ルートを「data.weather」として定義します
fields:['city','country']
しかし、国の値にアクセスできません
json ファイルの解析について説明してください。または、json ファイルをプレーン/テキストとしてロードする方法はありますか?