You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/12/16 22:59:38 UTC

thrift git commit: THRIFT-2894 PHP json serializer skips maps with int/bool keys Client: PHP Patch: Stig Bakken

Repository: thrift
Updated Branches:
  refs/heads/master 9f9535c5f -> a792e5d5a


THRIFT-2894 PHP json serializer skips maps with int/bool keys
Client: PHP
Patch: Stig Bakken <st...@zedge.net>

This closes #320

PHP generator: in jsonSerialize, only skip maps with non-scalar keys (previously skipped maps with non-string keys)


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/a792e5d5
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/a792e5d5
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/a792e5d5

Branch: refs/heads/master
Commit: a792e5d5ac8747f7f0d4b59c3a631bb86159fe18
Parents: 9f9535c
Author: Jens Geyer <je...@apache.org>
Authored: Tue Dec 16 22:47:02 2014 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Tue Dec 16 22:59:02 2014 +0100

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_php_generator.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/a792e5d5/compiler/cpp/src/generate/t_php_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc
index b45773c..c099354 100644
--- a/compiler/cpp/src/generate/t_php_generator.cc
+++ b/compiler/cpp/src/generate/t_php_generator.cc
@@ -1081,8 +1081,10 @@ void t_php_generator::generate_php_struct_json_serialize(ofstream& out,
       t_field* field = (*f_iter);
       t_type* type = field->get_type();
       const string& name = field->get_name();
-      if (type->is_map() && !((t_map*)type)->get_key_type()->is_string()) {
-        // JSON object keys must be strings
+      if (type->is_map() && !((t_map*)type)->get_key_type()->is_base_type()) {
+        // JSON object keys must be strings. PHP's json_encode()
+        // function will convert any scalar key to strings, but
+        // we skip thrift maps with non-scalar keys.
         continue;
       }
       indent(out) << "if ($this->" << name << " !== null) {" << endl;