diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2016-06-27 09:50:29 +0300 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2016-07-02 11:10:08 +0300 |
commit | d3fa561e5abcc88e02eb289c24d0b1d4d05adb54 (patch) | |
tree | 972f3a864d9e0d095b93de304df24d74943e8b96 /blobmsg_json.h | |
parent | d197c8ffa3cc61a747f318fd0ecef1f6e39b3935 (diff) |
blobmsg_json: add new functions blobmsg_format_json_value*
The current blobmsg_format_json* functions will return invalid JSON when
the "list" argument is given as false (blobmsg_format_element() will
output the name of the blob_attr as if the value is printed as part of a
JSON object).
To avoid breaking software relying on this behaviour, introduce new
functions which will never print the blob_attr name and thus always
produce valid JSON.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Acked-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Felix Fietkau <nbd@nbd.name> [cosmetic style fix]
Diffstat (limited to 'blobmsg_json.h')
-rw-r--r-- | blobmsg_json.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/blobmsg_json.h b/blobmsg_json.h index cd9ed33..9dfc02d 100644 --- a/blobmsg_json.h +++ b/blobmsg_json.h @@ -42,4 +42,18 @@ static inline char *blobmsg_format_json_indent(struct blob_attr *attr, bool list return blobmsg_format_json_with_cb(attr, list, NULL, NULL, indent); } +char *blobmsg_format_json_value_with_cb(struct blob_attr *attr, + blobmsg_json_format_t cb, void *priv, + int indent); + +static inline char *blobmsg_format_json_value(struct blob_attr *attr) +{ + return blobmsg_format_json_value_with_cb(attr, NULL, NULL, -1); +} + +static inline char *blobmsg_format_json_value_indent(struct blob_attr *attr, int indent) +{ + return blobmsg_format_json_value_with_cb(attr, NULL, NULL, indent); +} + #endif |