]>
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
31 bool use_json(const int argc
, struct cmd_token
*argv
[])
36 if (argv
[argc
- 1]->arg
&& strmatch(argv
[argc
- 1]->text
, "json"))
42 void json_object_string_add(struct json_object
*obj
, const char *key
,
45 json_object_object_add(obj
, key
, json_object_new_string(s
));
48 void json_object_int_add(struct json_object
*obj
, const char *key
, int64_t i
)
50 #if defined(HAVE_JSON_C_JSON_H)
51 json_object_object_add(obj
, key
, json_object_new_int64(i
));
53 json_object_object_add(obj
, key
, json_object_new_int((int)i
));
57 void json_object_boolean_false_add(struct json_object
*obj
, const char *key
)
59 json_object_object_add(obj
, key
, json_object_new_boolean(0));
62 void json_object_boolean_true_add(struct json_object
*obj
, const char *key
)
64 json_object_object_add(obj
, key
, json_object_new_boolean(1));
67 void json_object_boolean_add(struct json_object
*obj
, const char *key
, bool val
)
69 json_object_object_add(obj
, key
, json_object_new_boolean(val
));
72 struct json_object
*json_object_lock(struct json_object
*obj
)
74 return json_object_get(obj
);
77 void json_object_free(struct json_object
*obj
)
82 #if !defined(HAVE_JSON_C_JSON_H)
83 int json_object_object_get_ex(struct json_object
*obj
, const char *key
,
84 struct json_object
**value
)
86 *value
= json_object_object_get(obj
, key
);