I am passing a set of options as an object:
var options={
sortRules:[
{...}, // rule 1
{...}, // rule 2
// etc.
],
filterRules:[
{...}, // rule 1
{...}, // rule 2
// etc.
],
etc.
};
My issue: if any rule contains an "encodedName" property, I need to retrieve ASAP a dictionary of codes via a Web service. The dictionary is not needed if no "encodedName" property gets passed.
What is the most efficient way to check if an "encodedName" property is present within this object hierarchy? Looping through all the objects and sub-objects sounds painful, and I was wondering if there is a faster way.
[edit]: maybe I should have mentioned another idea I had: use JSON.stringify to turn the object into a string, then use indexOf search for "encodedName"
. I am not sure if it's more efficient than sub-object iteration though.