summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-09-13 15:50:25 -0700
committerBen Pfaff <blp@ovn.org>2017-10-24 16:09:17 -0700
commit52a9c55d558a68cd70391961ab561b01417464ff (patch)
tree3c16035fe5ec79f4583da267294b36ea1ac3c657 /lib
parentd697750af6e81c2a68a3b8b552a5ed98380e7d54 (diff)
downloadopenvswitch-52a9c55d558a68cd70391961ab561b01417464ff.tar.gz
json: New function json_object_put_format().
This will acquire users in an upcoming commit. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/json.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/json.c b/lib/json.c
index b98e60f87..5e93190b8 100644
--- a/lib/json.c
+++ b/lib/json.c
@@ -29,6 +29,7 @@
#include "openvswitch/shash.h"
#include "unicode.h"
#include "util.h"
+#include "uuid.h"
/* The type of a JSON token. */
enum json_token_type {
@@ -284,6 +285,17 @@ json_object_put_string(struct json *json, const char *name, const char *value)
json_object_put(json, name, json_string_create(value));
}
+void OVS_PRINTF_FORMAT(3, 4)
+json_object_put_format(struct json *json,
+ const char *name, const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ json_object_put(json, name,
+ json_string_create_nocopy(xvasprintf(format, args)));
+ va_end(args);
+}
+
const char *
json_string(const struct json *json)
{