All Downloads are FREE. Search and download functionalities are using the official Maven repository.

C-libcurl.object-body.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
#include 
#include 
#include 
#include "object.h"

object_t *object_create() {
    object_t *object = calloc(1, sizeof(object_t));

    return object;
}

void object_free(object_t *object) {
    if (!object) {
        return ;
    }

    if (object->temporary) {
        free(object->temporary);
        object->temporary = NULL;
    }

    free (object);
}

cJSON *object_convertToJSON(object_t *object) {
    if (!object) {
        return NULL;
    }

    if (!object->temporary) {
        return cJSON_Parse("null");
    }

    return cJSON_Parse(object->temporary);
}

object_t *object_parseFromJSON(cJSON *json){
    if (!json) {
        goto end;
    }

    object_t *object = object_create();
    if (!object) {
        goto end;
    }
    object->temporary = {{{cJSONPrint}}}(json);
    return object;

end:
    return NULL;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy