JSON: check to see if value is string or object

you can’t check JSON for whether or not they’re strings like regular variables?

this is not working for me…

 if (typeof propName === 'string') {  

in this example,
http://mayacove.com/dev/json/users.html

to grab for the “joined” property (which contains three values, so had to loop again…)

I had to “cheat” and do

 if(PropName === "joined") { 

but the line I really wanted to use, namely

 if (typeof propName === 'string') {  

was ignored…

but in my real situation need very much to detect whether a value is a string or an object… I assume this is pretty standard JSON stuff…

(in my real situation I need to check the Value, not the Prop name… and it’s the exact same problem…

this is ignored…

 if (typeof propValue === 'string') { 

)

thank you…

actually I made a mistake in my post…

the line I would have wanted to use here,
http://mayacove.com/dev/json/users.html
is

 //	if (PropValue != 'string') {  

to detect if value for “joined” was a string or an object…

but, again, this line was ignored…

In your JS, you’ve got this line:

if (PropValue typeOf != 'string')    //	this line is ignored....

The typeof operator is all lower case, and needs to go before the value you’re checking (as you’ve shown in previous posts). This should work:

$.each(val, function(PropName,PropValue) {
    if (typeof PropValue != 'string') {
        console.log(PropValue + ' is NOT a string');
    }
});