I'm trying to determine when or not a JSON object contains the word "cinema".
开发者_如何学JAVAIt is accessible through "obj.message"
so the check would be something like:
Pseudo-code - if (obj.message contains "cinema") display it
Is it possible to find text within a JSON object?
Thanks
alert(obj.message.indexOf("cinema") != -1);
Is obj.message itself an object? If so, the word is "in": if ("cinema" in obj.message)...
.
Or is obj.message an string? Then it's indexOf
, as Jacek_FH wrote.
if(obj.message.match(/cinema/))
would that work?
精彩评论