X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fjson.h;h=ef2312449b55c49a4ff4b42221f352c10c38a5f7;hb=8d71683b7632b5b621dd21418bf33ff90865b4e0;hp=7674015369232a767b6434a5f0c65573897f8f37;hpb=58fda1dab104041fc693032475ec4662c1a52849;p=sliver-openvswitch.git diff --git a/lib/json.h b/lib/json.h index 767401536..ef2312449 100644 --- a/lib/json.h +++ b/lib/json.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,12 @@ #include "shash.h" +#ifdef __cplusplus +extern "C" { +#endif + +struct ds; + /* Type of a JSON value. */ enum json_type { JSON_NULL, /* null */ @@ -76,6 +82,7 @@ struct json *json_array_create_empty(void); void json_array_add(struct json *, struct json *element); void json_array_trim(struct json *); struct json *json_array_create(struct json **, size_t n); +struct json *json_array_create_1(struct json *); struct json *json_array_create_2(struct json *, struct json *); struct json *json_array_create_3(struct json *, struct json *, struct json *); @@ -110,6 +117,7 @@ void json_parser_abort(struct json_parser *); struct json *json_from_string(const char *string); struct json *json_from_file(const char *file_name); +struct json *json_from_stream(FILE *stream); /* Serializing JSON. */ @@ -118,5 +126,16 @@ enum { JSSF_SORT = 1 << 1 /* Object members in sorted order, if true. */ }; char *json_to_string(const struct json *, int flags); +void json_to_ds(const struct json *, int flags, struct ds *); + +size_t json_serialized_length(const struct json *); + +/* JSON string formatting operations. */ + +bool json_string_unescape(const char *in, size_t in_len, char **outp); + +#ifdef __cplusplus +} +#endif #endif /* json.h */