diff options
author | kdx <kikoodx@paranoici.org> | 2024-01-24 09:27:36 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2024-01-24 09:27:36 +0100 |
commit | ca6b25303c7a5977a86d24fd54172608826a8abc (patch) | |
tree | 0b74fe0044d2de01251fead513dd4a84b5255668 | |
parent | aee126336212aadad63290c69ca5a6a313510e49 (diff) | |
download | tiled2c-ca6b25303c7a5977a86d24fd54172608826a8abc.tar.gz |
bool properties
-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},", |