mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 02:45:22 +00:00
THRIFT-1043 Fix how the length of a map is calculated
Patch: Wade Simmons git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1062278 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c7cd68eb86
commit
4b3f1c3181
@ -1478,7 +1478,7 @@ void t_js_generator::generate_serialize_container(ofstream &out,
|
||||
"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(" <<
|
||||
|
@ -713,5 +713,14 @@ Thrift.Protocol.prototype = {
|
||||
|
||||
}
|
||||
|
||||
Thrift.objectLength = function(obj) {
|
||||
var length = 0;
|
||||
for (k in obj) {
|
||||
if (obj.hasOwnProperty(k)) {
|
||||
length++;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,3 +128,7 @@ TApplicationException.prototype.write = function(output){
|
||||
output.writeFieldStop()
|
||||
output.writeStructEnd()
|
||||
}
|
||||
|
||||
exports.objectLength = function(obj) {
|
||||
return Object.keys(obj).length;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user