| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #include <zebra.h> |
| |
| #include "command.h" |
| #include "lib/json.h" |
| |
| |
| |
| |
| |
| |
| bool use_json(const int argc, struct cmd_token *argv[]) |
| { |
| if (argc == 0) |
| return false; |
| |
| if (argv[argc - 1]->arg && strmatch(argv[argc - 1]->text, "json")) |
| return true; |
| |
| return false; |
| } |
| |
| void json_object_string_add(struct json_object *obj, const char *key, |
| const char *s) |
| { |
| json_object_object_add(obj, key, json_object_new_string(s)); |
| } |
| |
| void json_object_int_add(struct json_object *obj, const char *key, int64_t i) |
| { |
| json_object_object_add(obj, key, json_object_new_int64(i)); |
| } |
| |
| void json_object_double_add(struct json_object *obj, const char *key, double i) |
| { |
| json_object_object_add(obj, key, json_object_new_double(i)); |
| } |
| |
| void json_object_boolean_false_add(struct json_object *obj, const char *key) |
| { |
| json_object_object_add(obj, key, json_object_new_boolean(0)); |
| } |
| |
| void json_object_boolean_true_add(struct json_object *obj, const char *key) |
| { |
| json_object_object_add(obj, key, json_object_new_boolean(1)); |
| } |
| |
| void json_object_boolean_add(struct json_object *obj, const char *key, bool val) |
| { |
| json_object_object_add(obj, key, json_object_new_boolean(val)); |
| } |
| |
| struct json_object *json_object_lock(struct json_object *obj) |
| { |
| return json_object_get(obj); |
| } |
| |
| void json_object_free(struct json_object *obj) |
| { |
| json_object_put(obj); |
| } |