Question about JSON?
Posted
by Alex
on Stack Overflow
See other posts from Stack Overflow
or by Alex
Published on 2010-04-22T15:46:26Z
Indexed on
2010/04/22
15:53 UTC
Read the original article
Hit count: 240
JSON
|JavaScript
Hi all,
I have a fairly simple question: In Javascript how can I return the boolean (if its found in the JSON) rather than the actual value?
Example:
var myJSON = {
"foo" : "bar",
"bar" : "foo"
};
var keyToLookFor = "foo";
var found = myJSON[keyToLookFor];
if (found) {
// I know I can test if the string exists in the if
}
// but is there a way I could just return something like:
return found;
// instead of testing found in the if statement and then returning true?
© Stack Overflow or respective owner