Well in the for..loop it seems to work now. But I have a similar issue now with an object.
I have this object:
Code: Select all
{
prokom_id: '',
liefergrund: '',
eintragsversion: {
bundesweit: '',
stichwort: '',
tb: '',
vab: '',
lieferanten_id: '',
gueltig_von: '',
gueltig_bis: '',
widerspruch: '',
nutzung: {
auskunft: '',
emedien: '',
pmedien: ''
},
einzeleintrag: {
eintragsdaten: {
eintragsdaten_id: '',
kz_neu_geaendert: '',
redak_key: '',
teilnehmerart: '',
gd_gt_zuordnung: '',
person_liste: {},
adresse: {
strasse: '',
hausnr: '',
hausnr_zusatz: '',
postfach: '',
plz: '',
postort: '',
gd_gt_nummer: '',
gemeinde: '',
gemeindeteil: '',
kuerzel: '',
geodaten: {
wgs84_x: '',
wgs84_y: '',
lcc_tao_x: '',
lcc_tao_y: '',
stadtteil: '',
qualitaet: ''
}
},
kommnr_liste: {},
zusatzdaten_infos: {
typ: '',
typ_text: '',
id_datenlieferant: '',
ergaenzungstext1_name: '',
ergaenzungstext2_name: '',
suchworte: '',
branding: '',
oeffnungszeiten_liste: {},
produkt_freigabe: {
nutzung_tb: '',
nutzung_gs: '',
nutzung_oetb: ''
},
emedien_freigabe: {
web: '',
mobil: '',
cd: '',
tv: ''
},
verlags_ids: {
tb: '',
oetb: '',
gs: ''
},
info_liste: {},
link_liste: {},
bewertung_liste: {}
}
}
}
}
}
In the first part of my script I read in all the lines of the XML and push the information into this blank object. At the end I have an Array of Objects.
Now I go through this Array and gather the informations to make API Calls. Before I do so i wanna check if the specific information is even there.
So in one case
Code: Select all
JSON.stringify( x[ i ]["eintragsversion"]["einzeleintrag"]["eintragsdaten"]["zusatzdaten_infos"]["produkt_freigabe"] );
gives me this object:
Code: Select all
{"nutzung_gs":"","nutzung_oetb":"","nutzung_tb":""}
Code: Select all
typeof x[ i ]["eintragsversion"]["einzeleintrag"]["eintragsdaten"]["zusatzdaten_infos"]["produkt_freigabe"]
gives me "object"
but when I try to get the length
Code: Select all
x[ i ]["eintragsversion"]["einzeleintrag"]["eintragsdaten"]["zusatzdaten_infos"]["produkt_freigabe"].length
I get the same error Trying to access undefined member 'length'
but when I check for undefined like
Code: Select all
typeof x[ i ]["eintragsversion"]["einzeleintrag"]["eintragsdaten"]["zusatzdaten_infos"]["produkt_freigabe"] == "undefined"
its false
So how can I make this work?