1 /*** 2 This file is part of PulseAudio. 3 4 Copyright 2016 Arun Raghavan <mail@arunraghavan.net> 5 6 PulseAudio is free software; you can redistribute it and/or modify 7 it under the terms of the GNU Lesser General Public License as published 8 by the Free Software Foundation; either version 2.1 of the License, 9 or (at your option) any later version. 10 11 PulseAudio 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. 15 16 You should have received a copy of the GNU Lesser General Public License 17 along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. 18 ***/ 19 20 #include <stdbool.h> 21 22 #define PA_DOUBLE_IS_EQUAL(x, y) (((x) - (y)) < 0.000001 && ((x) - (y)) > -0.000001) 23 24 typedef enum { 25 PA_JSON_TYPE_INIT = 0, 26 PA_JSON_TYPE_NULL, 27 PA_JSON_TYPE_INT, 28 PA_JSON_TYPE_DOUBLE, 29 PA_JSON_TYPE_BOOL, 30 PA_JSON_TYPE_STRING, 31 PA_JSON_TYPE_ARRAY, 32 PA_JSON_TYPE_OBJECT, 33 } pa_json_type; 34 35 typedef struct pa_json_object pa_json_object; 36 37 pa_json_object* pa_json_parse(const char *str); 38 pa_json_type pa_json_object_get_type(const pa_json_object *obj); 39 void pa_json_object_free(pa_json_object *obj); 40 41 /* All pointer members that are returned are valid while the corresponding object is valid */ 42 43 int pa_json_object_get_int(const pa_json_object *o); 44 double pa_json_object_get_double(const pa_json_object *o); 45 bool pa_json_object_get_bool(const pa_json_object *o); 46 const char* pa_json_object_get_string(const pa_json_object *o); 47 48 const pa_json_object* pa_json_object_get_object_member(const pa_json_object *o, const char *name); 49 50 int pa_json_object_get_array_length(const pa_json_object *o); 51 const pa_json_object* pa_json_object_get_array_member(const pa_json_object *o, int index); 52 53 bool pa_json_object_equal(const pa_json_object *o1, const pa_json_object *o2); 54