AJAX to get object and compare the json string data to the current value AJAX to get object and compare the json string data to the current value json json

AJAX to get object and compare the json string data to the current value


When you have the json value of key value pair use the following code to get the url.

jsonKeyValuePair // assuming this variable has key value pair, having url.var jsonData = JSON.parse(jsonKeyValuePair)console.log(jsonData.url) // this should give you the url value // You can now compareif(jsonData.url === currentTab.url) {  // Do your calculation.}

Hope this helps.


The simplest and cleanest way you can compare is using Filter to match the urls in JSON object.

let currentTab = tabs[0]; // Url for comparing//jsonObj contains all the json urlslet matchedUrl= jsonObj.filter(function(item) {  return item.url === currentTab.url;});console.log(matchedUrl);