void VariableSerializer::write(CObjRef v) {
  if (!v.isNull() && m_type == JSON) {
    if (incNestedLevel(v.get(), true)) {
      writeOverflow(v.get(), true);
    } else {
      Array props(ArrayData::Create());
      ClassInfo::GetArray(v.get(), v->o_getClassPropTable(), props, true);
      setObjectInfo(v->o_getClassName(), v->o_getId());
      props.serialize(this);
    }
    decNestedLevel(v.get());
  } else {
    v.serialize(this);
  }
}
Пример #2
0
void VariableSerializer::write(CObjRef v) {
  if (!v.isNull() && m_type == JSON) {
    Array props = v->o_toArray();
    ClassInfo::PropertyVec properties;
    ClassInfo::GetClassProperties(properties, v->o_getClassName());
    for (ClassInfo::PropertyVec::const_iterator iter = properties.begin();
         iter != properties.end(); ++iter) {
      if ((*iter)->attribute & ClassInfo::IsProtected) {
        props.remove((*iter)->name);
      }
    }
    // Remove private props
    for (ArrayIter it(props); !it.end(); it.next()) {
      if (it.first().toString().charAt(0) == '\0') {
        props.remove(it.first());
      }
    }
    setObjectInfo(v->o_getClassName(), v->o_getId());
    props.serialize(this);
  } else {
    v.serialize(this);
  }
}