]>
git.proxmox.com Git - mirror_frr.git/blob - lib/json.c
2 * Copyright (C) 2015 Cumulus Networks, Inc.
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 * This function assumes that the json keyword
28 * is the *last* keyword on the line no matter
32 use_json (const int argc
, struct cmd_token
*argv
[])
37 if (argv
[argc
-1]->arg
&& strmatch (argv
[argc
-1]->text
, "json"))
44 json_object_string_add(struct json_object
* obj
, const char *key
,
47 json_object_object_add(obj
, key
, json_object_new_string(s
));
51 json_object_int_add(struct json_object
* obj
, const char *key
, int64_t i
)
53 #if defined(HAVE_JSON_C_JSON_H)
54 json_object_object_add(obj
, key
, json_object_new_int64(i
));
56 json_object_object_add(obj
, key
, json_object_new_int((int)i
));
61 json_object_boolean_false_add(struct json_object
* obj
, const char *key
)
63 json_object_object_add(obj
, key
, json_object_new_boolean(0));
67 json_object_boolean_true_add(struct json_object
* obj
, const char *key
)
69 json_object_object_add(obj
, key
, json_object_new_boolean(1));
73 json_object_lock(struct json_object
*obj
)
75 return json_object_get(obj
);
79 json_object_free(struct json_object
*obj
)
84 #if !defined(HAVE_JSON_C_JSON_H)
86 json_object_object_get_ex(struct json_object
*obj
,
88 struct json_object
**value
)
90 *value
= json_object_object_get(obj
, key
);