diff --git a/dexter.c b/dexter.c index d943a8b..4dc49d6 100644 --- a/dexter.c +++ b/dexter.c @@ -99,6 +99,11 @@ unlink(xmlNodePtr xml) { } } +static bool +is_root(xmlElementPtr xml) { + return xml != NULL && xml->name != NULL && xml->prefix !=NULL && !strcmp(xml->name, "root") && !strcmp(xml->prefix, "dexter"); +} + static void prune(parsedDexPtr ptr, xmlNodePtr xml, char* err) { if(xml == NULL) return; diff --git a/test/empty.json b/test/empty.json index 0967ef4..ffcd441 100644 --- a/test/empty.json +++ b/test/empty.json @@ -1 +1 @@ -{} +{ } diff --git a/xml2json.c b/xml2json.c index a866c41..7e35975 100644 --- a/xml2json.c +++ b/xml2json.c @@ -3,10 +3,7 @@ #include "xml2json.h" #include -/** - * Handles a simplified xml - */ -struct json_object * xml2json(xmlNodePtr xml) { +static struct json_object * _xml2json(xmlNodePtr xml) { if(xml == NULL) return NULL; xmlNodePtr child; @@ -39,4 +36,13 @@ struct json_object * xml2json(xmlNodePtr xml) { break; } return json; -} \ No newline at end of file +} + +/** + * Handles a simplified xml + */ +struct json_object * xml2json(xmlNodePtr xml) { + struct json_object * json = _xml2json(xml); + if(json == NULL) json = json_object_new_object(); + return json; +}