I have a json from an wordpress endpoint and want to test if testState contains not key and values but only {}.
function testFunction() {
return json_decode('{
"testData": [
{
"_id": "1",
"name": "testName1"
},
{
"_id": "2",
"name": "testName2"
},
],
"testState": {
}
}'); }
here the ajax code which is not working
jQuery.ajax({
type: 'POST',
dataType: 'json',
url: '/wp-admin/admin-ajax.php',
data: {
action: 'testFunction'
},
success: function(result) {
if(result.serviceState == '{}'){
console.log(result);
}
what is the right syntax to do something like if(result.serviceState == '{}')?