gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 06:36:58 25 4
gpt4 key购买 nike

我的脚本运行良好

$.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例如给我“未定义”错误。

最佳答案

Code_Demandeur 驻留在 对象 中,该对象位于数组的第 0 索引

$.getJSON("../Conseiller/EditerDemandeurs_MenuConseiller", {
sIdDdeur: idDdeur
}, function(data, status) {
console.log(data.rows[0].Code_Demandeur);
});

关于javascript - 如何将json数据提取到变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38155782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com