Bonjour,

J'ai un script php qui se connecte à une base de données et me renvoie un json.

mon script :
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
$sp = $_GET['sp'];
 
if ($sp!='') {
 
$client = new SoapClient("monurl");
$AphiaID=$client->getAphiaID($sp);
 
$taxon=$client->getAphiaRecordByID($AphiaID);
 
if ($taxon->scientificname == '') {$json='{"success":false, "data": {';}
else {$json='{"success":true, "data": [{';}
 
//$class=$client->getAphiaClassificationByID($AphiaID);
 
$json = $json.'"scname": "'.$taxon->scientificname.'" , ';	// nom scientifique
$json = $json.'"AphiaID": '.$taxon->AphiaID.', ';		// code WoRMS
$json = $json.'"authority": "'.$taxon->authority.'", ';		// authority
$json = $json.'"url": "'.$taxon->url.'", ';			// url de la fiche d'identité
$json = $json.'"phylum": "'.$taxon->phylum.'", ';		// phylum
$json = $json.'"class": "'.$taxon->class.'", ';			// classe
$json = $json.'"order": "'.$taxon->order.'", ';			// ordre
$json = $json.'"family": "'.$taxon->family.'", ';		// famille
 
$json = substr($json,0,-2);
 
}	// fin if ($sp!='') {
 
$json = $json.'}]}';
 
echo $json;
exemple de json retourné :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
{"success":true, "data": [{"scname": "Abra alba" , "AphiaID": 141433, "authority": "(W. Wood, 1802)", "url": "monurl", "phylum": "Mollusca", "class": "Bivalvia", "order": "Veneroida", "family": "Semelidae"}]}
je veux afficher les éléments du json dans un FormPanel :
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
var formSP = new Ext.form.FormPanel({
			width: 800,
			loadMask: new Ext.LoadMask(Ext.getBody(), {msg:"Loading..."}),
			items: [{
				xtype: 'textfield',
				fieldLabel: 'Nom scientifique',
				name: 'scname',
				value: store.getAt(0).get('scname')
				},
				{
				xtype: 'textfield',
				fieldLabel: 'AphiaID',
				name: 'AphiaID',
				value: store.getAt(0).get('AphiaID')
				},
				{
				xtype: 'textfield',
				fieldLabel: 'Nom commun',
				name: 'phylum',
				value: store.getAt(0).get('phylum')
				},
				{
				xtype: 'textfield',
				fieldLabel: 'Classification',
				name: 'order',
				value: store.getAt(0).get('order')
				}
			]
	});
les champs scname et AphiaID s'affichent bien, mais dans les champs phylum et order, il n'y a rien.
pourtant, le json en sortie est correct (testé sur http://jsonlint.com/).

une idée ?

Merci,
Nico