开发者

jQuery find word in JSON object

I'm trying to determine when or not a JSON object contains the word "cinema".

开发者_如何学JAVA

It 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜