diff options
author | Ben Pfaff <blp@nicira.com> | 2015-04-02 22:36:31 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2015-04-20 14:02:48 -0700 |
commit | 3b6267714bd4a426cbd4d8da1d8328f5f6760446 (patch) | |
tree | ab1d1f06bd8b1d4dee96b9413f484ec5e6a60601 /lib/json.c | |
parent | f4471a05421e69a3be621b26176bf20b1f7e627e (diff) | |
download | openvswitch-3b6267714bd4a426cbd4d8da1d8328f5f6760446.tar.gz |
json: New function json_string_escape().
This saves some cut-and-paste duplicated code elsewhere and will have
additional users in upcoming commits.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
Diffstat (limited to 'lib/json.c')
-rw-r--r-- | lib/json.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/json.c b/lib/json.c index f004771e1..11cf03846 100644 --- a/lib/json.c +++ b/lib/json.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012, 2014 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2014, 2015 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -879,6 +879,16 @@ exit: return ok; } +void +json_string_escape(const char *in, struct ds *out) +{ + struct json json = { + .type = JSON_STRING, + .u.string = CONST_CAST(char *, in), + }; + json_to_ds(&json, 0, out); +} + static void json_parser_input_string(struct json_parser *p, const char *s) { |