You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imagine you have an xml file in which an element is repeated zero or more
times. You could have these three files following that scheme:
File 1:
<a></a>
File 2:
<a><b>1</b></a>
File 3:
<a><b>1</b><b>2</b></a>
Now, if I convert this xml to the object "obj", obj.a.b can either be
undefined, a string or an array of strings. x2js.asArray(obj.a.b) will always
be an array. However, for files 2 and 3 it will be an array of strings, while
for file 1 it will be [undefined], while what I (clearly) wanted was an empty
array (of strings).
Returning an empty array should be simple in this case and will help prevent
errors when it turns out the element you are looking for is repeated zero times.
Original issue reported on code.google.com by jasperh...@gmail.com on 27 Jun 2014 at 11:26
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
jasperh...@gmail.com
on 27 Jun 2014 at 11:26The text was updated successfully, but these errors were encountered: