aboutsummaryrefslogtreecommitdiff
path: root/ruby/ext/google/protobuf_c/defs.c
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2016-04-14 18:33:17 -0700
committerJosh Haberman <jhaberman@gmail.com>2016-04-14 18:33:17 -0700
commit194ad621bb7260c4f2f27f3575ce21ab946b786c (patch)
tree9b1e0fedfdd2857a3312e1c383eb697207e53645 /ruby/ext/google/protobuf_c/defs.c
parent90c7f6e55eb43d89f345fc4412a99ac9477055da (diff)
downloadprotobuf-194ad621bb7260c4f2f27f3575ce21ab946b786c.tar.gz
protobuf-194ad621bb7260c4f2f27f3575ce21ab946b786c.tar.bz2
protobuf-194ad621bb7260c4f2f27f3575ce21ab946b786c.zip
Ruby JSON: always accept both camelCase and original field names.
For JSON encoding we provide a new option to decide at encode time whether to use camelCase or original proto field names: json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true)
Diffstat (limited to 'ruby/ext/google/protobuf_c/defs.c')
-rw-r--r--ruby/ext/google/protobuf_c/defs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c
index 96ef4953..7e93bafb 100644
--- a/ruby/ext/google/protobuf_c/defs.c
+++ b/ruby/ext/google/protobuf_c/defs.c
@@ -255,6 +255,10 @@ void Descriptor_free(void* _self) {
upb_handlers_unref(self->json_serialize_handlers,
&self->json_serialize_handlers);
}
+ if (self->json_serialize_handlers_preserve) {
+ upb_handlers_unref(self->json_serialize_handlers_preserve,
+ &self->json_serialize_handlers_preserve);
+ }
xfree(self);
}
@@ -278,6 +282,7 @@ VALUE Descriptor_alloc(VALUE klass) {
self->json_fill_method = NULL;
self->pb_serialize_handlers = NULL;
self->json_serialize_handlers = NULL;
+ self->json_serialize_handlers_preserve = NULL;
self->typeclass_references = rb_ary_new();
return ret;
}