diff options
author | Sree Kuchibhotla <sreek@google.com> | 2018-07-20 10:29:08 -0700 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2018-07-20 10:29:08 -0700 |
commit | b5b0fbf0858814514a0eb9572be5e10e65c1dfb6 (patch) | |
tree | a8d13845c0f7f9379f25fa9153c8069ef189d69c /src/core/lib/json/json.cc | |
parent | 68ad431864c59faa378df78faf280606296e3a6e (diff) | |
parent | e6824f3c1d14fd300ebef29bb2bfbc5bc734456a (diff) |
Merge branch 'master' into fix-dns-job-2
Diffstat (limited to 'src/core/lib/json/json.cc')
-rw-r--r-- | src/core/lib/json/json.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/lib/json/json.cc b/src/core/lib/json/json.cc index 816241bbf0..e78b73cefd 100644 --- a/src/core/lib/json/json.cc +++ b/src/core/lib/json/json.cc @@ -18,10 +18,12 @@ #include <grpc/support/port_platform.h> +#include <inttypes.h> #include <string.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include "src/core/lib/json/json.h" @@ -56,6 +58,8 @@ void grpc_json_destroy(grpc_json* json) { grpc_json* grpc_json_link_child(grpc_json* parent, grpc_json* child, grpc_json* sibling) { + // link child up to parent + child->parent = parent; // first child case. if (parent->child == nullptr) { GPR_ASSERT(sibling == nullptr); @@ -79,8 +83,15 @@ grpc_json* grpc_json_create_child(grpc_json* sibling, grpc_json* parent, grpc_json* child = grpc_json_create(type); grpc_json_link_child(parent, child, sibling); child->owns_value = owns_value; - child->parent = parent; child->value = value; child->key = key; return child; } + +grpc_json* grpc_json_add_number_string_child(grpc_json* parent, grpc_json* it, + const char* name, int64_t num) { + char* num_str; + gpr_asprintf(&num_str, "%" PRId64, num); + return grpc_json_create_child(it, parent, name, num_str, GRPC_JSON_STRING, + true); +} |