File tree Expand file tree Collapse file tree
samples/client/petstore/c/model Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,11 +42,9 @@ cJSON *api_response_convertToJSON(api_response_t *api_response) {
4242 cJSON * item = cJSON_CreateObject ();
4343
4444 // api_response->code
45- if (api_response -> code ) {
4645 if (cJSON_AddNumberToObject (item , "code" , api_response -> code ) == NULL ) {
4746 goto fail ; //Numeric
4847 }
49- }
5048
5149
5250 // api_response->type
Original file line number Diff line number Diff line change @@ -36,11 +36,9 @@ cJSON *category_convertToJSON(category_t *category) {
3636 cJSON * item = cJSON_CreateObject ();
3737
3838 // category->id
39- if (category -> id ) {
4039 if (cJSON_AddNumberToObject (item , "id" , category -> id ) == NULL ) {
4140 goto fail ; //Numeric
4241 }
43- }
4442
4543
4644 // category->name
Original file line number Diff line number Diff line change @@ -61,27 +61,21 @@ cJSON *order_convertToJSON(order_t *order) {
6161 cJSON * item = cJSON_CreateObject ();
6262
6363 // order->id
64- if (order -> id ) {
6564 if (cJSON_AddNumberToObject (item , "id" , order -> id ) == NULL ) {
6665 goto fail ; //Numeric
6766 }
68- }
6967
7068
7169 // order->pet_id
72- if (order -> pet_id ) {
7370 if (cJSON_AddNumberToObject (item , "petId" , order -> pet_id ) == NULL ) {
7471 goto fail ; //Numeric
7572 }
76- }
7773
7874
7975 // order->quantity
80- if (order -> quantity ) {
8176 if (cJSON_AddNumberToObject (item , "quantity" , order -> quantity ) == NULL ) {
8277 goto fail ; //Numeric
8378 }
84- }
8579
8680
8781 // order->ship_date
@@ -102,11 +96,9 @@ cJSON *order_convertToJSON(order_t *order) {
10296
10397
10498 // order->complete
105- if (order -> complete ) {
10699 if (cJSON_AddBoolToObject (item , "complete" , order -> complete ) == NULL ) {
107100 goto fail ; //Bool
108101 }
109- }
110102
111103 return item ;
112104fail :
Original file line number Diff line number Diff line change @@ -79,11 +79,9 @@ cJSON *pet_convertToJSON(pet_t *pet) {
7979 cJSON * item = cJSON_CreateObject ();
8080
8181 // pet->id
82- if (pet -> id ) {
8382 if (cJSON_AddNumberToObject (item , "id" , pet -> id ) == NULL ) {
8483 goto fail ; //Numeric
8584 }
86- }
8785
8886
8987 // pet->category
Original file line number Diff line number Diff line change @@ -36,11 +36,9 @@ cJSON *tag_convertToJSON(tag_t *tag) {
3636 cJSON * item = cJSON_CreateObject ();
3737
3838 // tag->id
39- if (tag -> id ) {
4039 if (cJSON_AddNumberToObject (item , "id" , tag -> id ) == NULL ) {
4140 goto fail ; //Numeric
4241 }
43- }
4442
4543
4644 // tag->name
Original file line number Diff line number Diff line change @@ -68,11 +68,9 @@ cJSON *user_convertToJSON(user_t *user) {
6868 cJSON * item = cJSON_CreateObject ();
6969
7070 // user->id
71- if (user -> id ) {
7271 if (cJSON_AddNumberToObject (item , "id" , user -> id ) == NULL ) {
7372 goto fail ; //Numeric
7473 }
75- }
7674
7775
7876 // user->username
@@ -124,11 +122,9 @@ cJSON *user_convertToJSON(user_t *user) {
124122
125123
126124 // user->user_status
127- if (user -> user_status ) {
128125 if (cJSON_AddNumberToObject (item , "userStatus" , user -> user_status ) == NULL ) {
129126 goto fail ; //Numeric
130127 }
131- }
132128
133129 return item ;
134130fail :
You can’t perform that action at this time.
0 commit comments