In a given Json, search for the particular given string based on key, return true if found, else false Using jQuery/Javascript
Posted
by
NaanuManu
on Stack Overflow
See other posts from Stack Overflow
or by NaanuManu
Published on 2012-10-10T03:32:44Z
Indexed on
2012/10/10
3:36 UTC
Read the original article
Hit count: 223
Given JSON String/object
{"selectAll":false,"include":{"country_197":{"id":"197","data_type":"country","name":"Singapore","desc":"","parent_key_id":"all_all","status":""},"country_100":{"id":"100","data_type":"country","name":"India","desc":"","parent_key_id":"all_all","status":""}},"exclude":{"state_2":{"id":"2","data_type":"state","name":"Andhra Pradesh","desc":"","parent_key_id":"country_100","status":""}}}
Given search string is: country_100
Required :
Have to search for country_100 in Given JSON String/object by key parent_key_id
Ex: searching country_100 is found :
{"selectAll":false,"include":{"country_197":{"id":"197","data_type":"country","name":"Singapore","desc":"","parent_key_id":"all_all","status":""},"country_100":{"id":"100","data_type":"country","name":"India","desc":"","parent_key_id":"all_all","status":""}},"exclude":{"state_2":{"id":"2","data_type":"state","name":"Andhra Pradesh","desc":"","parent_key_id":"**country_100**","status":""}}}
So return True, else return false
please help me in finding a solution.
© Stack Overflow or respective owner