diff options
-rw-r--r-- | src/main.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -21,6 +21,12 @@ return -1; \ } +#define JSON_GET_BOOL(j, s) JSON_GET(j, s); \ + if (!cJSON_IsBool(s)) { \ + fprintf(stderr, #s " is no bool\n"); \ + return -1; \ + } + #define JSON_GET_ARRAY(j, s) JSON_GET(j, s); \ if (!cJSON_IsArray(s)) { \ fprintf(stderr, #s " is no array\n"); \ @@ -96,6 +102,11 @@ process_property(cJSON *json) if (type->valuestring[0] == 's') { JSON_GET_STRING(json, value); printf("\"%s\",0},", value->valuestring); + } else if (type->valuestring[0] == 'b') { + JSON_GET_BOOL(json, value); + printf("\"%s\",%d},", + value->valueint ? "true" : "false", + value->valueint); } else { JSON_GET(json, value); printf("\"%f\",%f},", |