开发者

jQuery find word in JSON object

开发者 https://www.devze.com 2023-03-26 23:08 出处:网络
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:

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

精彩评论

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