"output.writeMapBegin(" <<
type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
type_to_enum(((t_map*)ttype)->get_val_type()) << ", " <<
- prefix << ".length)" << endl;
+ "Thrift.objectLength(" << prefix << "))" << endl;
} else if (ttype->is_set()) {
indent(out) <<
"output.writeSetBegin(" <<
}
+Thrift.objectLength = function(obj) {
+ var length = 0;
+ for (k in obj) {
+ if (obj.hasOwnProperty(k)) {
+ length++;
+ }
+ }
+ return length;
+}
output.writeFieldStop()
output.writeStructEnd()
}
+
+exports.objectLength = function(obj) {
+ return Object.keys(obj).length;
+}