aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/json/json.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lib/json/json.cc')
-rw-r--r--src/core/lib/json/json.cc13
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);
+}