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

C-libcurl.model_user_test.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
#include 
#include 
#include 
#include "cJSON.h"
#include "user.h"


#define USER_ID 1234
#define USER_NAME "example123"
#define FIRST_NAME "Example1"
#define LAST_NAME "Example2"
#define EMAIL "[email protected]"
#define PASSWORD "thisisexample!123"
#define PHONE "+123456789"
#define USER_STATUS 4

int main() {


user_t *newuser = user_create(USER_ID, USER_NAME, FIRST_NAME, LAST_NAME, EMAIL,
PASSWORD, PHONE, USER_STATUS );

cJSON *JSONNODE = user_convertToJSON(newuser);

char *dataToPrint = cJSON_Print(JSONNODE);

printf("Created User is: \n%s\n",dataToPrint);

user_t *parsedUser = user_parseFromJSON( dataToPrint);

cJSON *fromJSON = user_convertToJSON(parsedUser);

char *dataToPrintFromJSON = cJSON_Print(fromJSON);

printf("Parsed User From JSON is: \n%s\n",dataToPrintFromJSON);

user_free(newuser);
user_free(parsedUser);
cJSON_Delete(JSONNODE);
cJSON_Delete(fromJSON);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy