2010-10-05 4 views
0
Parsing

J'ai essayé et la recherche sans success.I faibli pour analyser la chaîne JSON suivante:JSON AS3

{ "label": "Mon serveur ncWMS", "enfants": [{ "label": "champ", "enfants": [{"id": "champion/XE", "label": "sea_surface_height_above_geoid"}, {"id": "champ/U", "label": "barotropique_eastward_sea_water_velocity"}, {"id": "champion/V", "label": "barotropic_northward_sea_water_velocity"}, {"id": "champion/UZ", "label": "eastward_sea_water_velocity"}, {"id": "champion/VZ" , "label": "northward_sea_water_velocity"}, {"id": "champ/SAL", "label": "sea_water_salinity"}, {"id": "champ/TEMP", "label": "sea_water_temperature"}, {"id": "champion/H0", "label": "sea_floor_depth_below_geoid"}, {"id": "champion/HX", "label": "sea_floor_depth_below_geoid_u_location"}, {"id": "champion/HY" , "label": "sea_floor_depth_below_geoid_v_l ocation "}, {" id ":" champion/barotropic_sea_water_velocity "," label ":" barotropic_sea_water_velocity "}, {" id ":" champion/sea_water_velocity "," label ":" sea_water_velocity "]] }]}]}

mais l'objet résultant du décodage as3 json est toujours nul: var analysé: Object = JSON.decode (event.result as String) en tant qu'objet;

Quelqu'un pourrait-il me donner un indice?

Merci beaucoup! G

+0

Pourriez-vous s'il vous plaît formater votre JSON? Consultez la FAQ pour obtenir des conseils sur les bonnes techniques de formatage. –

Répondre

0

Oui, en effet, mon copier-coller a échoué. Mais avec une chaîne JSON correcte, j'avais toujours une erreur. Ce qui a fonctionné:

public function onResultLoadFiles(event:ResultEvent):void{ 
     var jsonString:String = StringUtil.trim(String(event.result)); 
     if ((String(event.result) != null) && (String(event.result) != "")) { 
      var j:Object = JSON.decode(jsonString); 
      var server_label:String = j.label; 
     } 
     trace(server_label) 
}