JS json.parse "null" values
I don’t know if this is “proper” or “pretty”, but couldn’t you just use
if(jParsed[i]){
…
}
I don’t know if this is “proper” or “pretty”, but couldn’t you just use
if(jParsed[i]){
…
}
I have tested it too, but it returns True even for “null” objects. Really I don’t understand why.
Actually I have done a new JS code block:
for (var i = 0; i < jParsed.length; i++) {
var temp = JSON.stringify(jParsed[i]);
if (jParsed[i] != “null”) {
//listIds.push(jBank[it].id);
}
}
The last solution works but I hope that could be an easier/faster way to check an object directly without stringify it again..
The only thing that comes to mind then is that your initial “null” is not the null object. Is it perhaps already a string, or some other form?
The only thing that comes to mind then is that your initial “null” is not the null object. Is it perhaps already a string, or some other form?
No it was an object. Now (after a PC crash) all works with “if (jParsed[i] != null)”, maybe something went wrong with visual studio debug -_-
I’m assuming it must have been something wrong with the visual studio debug. Your code should (and does) work.
Here’s a JS fiddle: https://jsfiddle.net/eq8wb3t0/2/
(edited by potatofarms.9241)
I’m assuming it must have been something wrong with the visual studio debug. Your code should (and does) work.
Here’s a JS fiddle: https://jsfiddle.net/eq8wb3t0/2/
Yes it was visual studio. It was hard to imagine that visual studio debug could be bugged
Thank you for your help guys