如何将json数据提取到变量中

时间:2016-07-02 01:54:17

标签: javascript jquery json

我的脚本运行正常

$.getJSON("../Conseiller/EditerDemandeurs_MenuConseiller",{sIdDdeur: idDdeur}, function (data, status) {
    var result = JSON.stringify(data);
    console.log(data);
    console.log(result);
});

当我将其传递给console.log时,它会给出:

Object {rows: Array[1]}
ModalForms.js:10 {"rows":[{"Code_Demandeur":"DD_ANLI000003","Nom_Demandeur":"Anderson","Prenoms_Demandeur":"Liam","UserId":null,"Adresse_Demandeur":"1136 AllEe Gerard Morisset Monarque","Ville":"Saint-Eugène-d'Argentenay (MunicipalitE de)","Province":"QuEbec","CodePostal_Demandeur":"H7A2A7","Tel1_Demandeur":"4180010502          ","Tel2_Demandeur":"5141921617          ","Tel3_Demandeur":null,"Courriel1_Demandeur":"Doiron _Joshua@live.ca","Courriel2_Demandeur":null,"Courriel3_Demandeur":null,"SitMat":"Couple avec enfant","Sexe":"Femme","Date_Naissance_Demandeur":"/Date(-642542400000)/","Revenu_Demandeur":null,"Occupation":"INFIRMIER","Scolarite":"Doctorat","StatutLegal":"REsident permanent","Communaute":"Africaine","SourceInformation":"Accès travail emploi femme","Handicape":false,"Reference":null,"Remarques_Demandeur":null,"ID_Photo":null,"Actif_Inactif":true,"Dte_Saisie":"/Date(1464913323033)/","ID_Utilisateur":1,"Nom_Type_Demandeur":"Principal"}]}

我的问题是如何将这些值分配给变量?
例如,使用xx = data.Code_Demandeur会给我“未定义”错误。

1 个答案:

答案 0 :(得分:1)

Code_Demandeur位于object 0的{​​{1}}索引{/ 1}}

array