forked from loafle/openapi-generator-original
40 lines
976 B
C
40 lines
976 B
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "../model/user.h"
|
|
|
|
|
|
#define USER_ID 1234
|
|
#define USER_NAME "example123"
|
|
#define FIRST_NAME "Example1"
|
|
#define LAST_NAME "Example2"
|
|
#define EMAIL "example@example.com"
|
|
#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(JSONNODE);
|
|
|
|
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);
|
|
}
|