Bonjour,

J'ai une question sur la syntaxe pour récupérer des données json dans un tableau, pour un tableau comme celui-ci j'y arrive bien :

Fichier data.json :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
{"datajson":[
    { "axis":"12 am", "value":"1000 vues"},
    { "axis":"3 am", "value":"4000 vues"},
    { "axis":"6 am", "value":"6000 vues"},
	{ "axis":"9 am", "value":"1500 vues"},
	{ "axis":"12 pm", "value":"2500 vues"},
	{ "axis":"3 pm", "value":"3500 vues"},
	{ "axis":"6 pm", "value":"4500 vues"},
	{ "axis":"9 pm", "value":"5500 vues"}
],
"datajson1":[
    { "axis":"12 am", "value":"3000 vues"},
    { "axis":"3 am", "value":"5000 vues"},
    { "axis":"6 am", "value":"7000 vues"},
	{ "axis":"9 am", "value":"2500 vues"},
	{ "axis":"12 pm", "value":"3500 vues"},
	{ "axis":"3 pm", "value":"4500 vues"},
	{ "axis":"6 pm", "value":"5500 vues"},
	{ "axis":"9 pm", "value":"6500 vues"}
]
}
Pour récupérer 1000 par exemple je fais :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
$.getJSON('data.json', function(data_json) {
span.append(data_json.datajson[0].value)
});
Mais j'ai un problème pour un tableau plus gros comme celui-ci :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Fichier data.json :
 
[  
  {  
    "key":"iPhone",
    "values":[  
      {  
        "axis":"Battery Life",
        "value":0.2
      },
      {  
        "axis":"Brand",
        "value":0.28
      },
      {  
        "axis":"Contract Cost",
        "value":0.29
      },
      {  
        "axis":"Design And Quality",
        "value":0.17
      },
      {  
        "axis":"Have Internet Connectivity",
        "value":0.22
      },
      {  
        "axis":"Large Screen",
        "value":0.02
      },
      {  
        "axis":"Price Of Device",
        "value":0.21
      },
      {  
        "axis":"To Be A Smartphone",
        "value":0.50
      }
    ]
  },
  {  
    "key":"Samsung",
    "values":[  
      {  
        "axis":"Battery Life",
        "value":0.27
      },
      {  
        "axis":"Brand",
        "value":0.16
      },
      {  
        "axis":"Contract Cost",
        "value":0.35
      },
      {  
        "axis":"Design And Quality",
        "value":0.13
      },
      {  
        "axis":"Have Internet Connectivity",
        "value":0.20
      },
      {  
        "axis":"Large Screen",
        "value":0.13
      },
      {  
        "axis":"Price Of Device",
        "value":0.35
      },
      {  
        "axis":"To Be A Smartphone",
        "value":0.38
      }
    ]
  },
  {  
    "key":"Nokia Smartphone",
    "values":[  
      {  
        "axis":"Battery Life",
        "value":0.26
      },
      {  
        "axis":"Brand",
        "value":0.10
      },
      {  
        "axis":"Contract Cost",
        "value":0.30
      },
      {  
        "axis":"Design And Quality",
        "value":0.14
      },
      {  
        "axis":"Have Internet Connectivity",
        "value":0.22
      },
      {  
        "axis":"Large Screen",
        "value":0.04
      },
      {  
        "axis":"Price Of Device",
        "value":0.41
      },
      {  
        "axis":"To Be A Smartphone",
        "value":0.30
      }
    ]
  }
]
Imaginons que je veuille récupérer la valeur 0.2 de Iphone, je n'arrive pas à trouver la bonne syntaxe.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
$.getJSON('data.json', function(data_json) {
span.append(data_json.Ici je ne sais pas quoi mettre)
});
Voilà si quelqu'un peut me venir en aide, j'ai essayé des combinaisons mais sans succès.