に投稿

特定のプロパティを探して返す関数

  function getProp(rootObj, nestingLevel, name) {
    var propTo;
    dumpPropTree(rootObj, nestingLevel, name);
    function dumpPropTree(rootObj, nestingLevel, name) {
      var countProps = rootObj.numProperties;
      for (var propIndex = 1; propIndex <= countProps; propIndex++) {
        var prop = rootObj.property(propIndex);
        if (prop.name == name) {
          propTo = prop;
          return;
        } else {
          dumpPropTree(prop, nestingLevel + 1, name);
        }
      }
    }
    return propTo;
  }