Skip to content

Commit

Permalink
Remove yajl_to_json no longer needed
Browse files Browse the repository at this point in the history
Signed-off-by: Sourav Moitra <[email protected]>
  • Loading branch information
xw19 committed Nov 20, 2024
1 parent 1de626e commit 6d1252a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
37 changes: 0 additions & 37 deletions src/ocispec/json_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1903,43 +1903,6 @@ json_marshal_string (const char *str, size_t length, const struct parser_context
return json_buf;
}

/*
This function is temporary function to convert yajl_val. This fuction will
not be required once we completely move to jansson
Input: yajl_val
Output: json_t
*/
json_t *yajl_to_json(yajl_val val) {
if YAJL_IS_NULL(val) {
return json_null();
} else if (YAJL_IS_TRUE(val)) {
return json_true();
} else if (YAJL_IS_FALSE(val)) {
return json_false();
} else if (YAJL_IS_DOUBLE(val)) {
return json_real(YAJL_GET_DOUBLE(val));
} else if (YAJL_IS_INTEGER(val)) {
return json_integer(YAJL_GET_INTEGER(val));
} else if (YAJL_IS_STRING(val)) {
return json_string(YAJL_GET_STRING(val));
} else if (YAJL_IS_ARRAY(val)) {
json_t *jansson_array = json_array();
for (size_t i = 0; i < val->u.array.len; i++) {
json_array_append(jansson_array, yajl_to_json(val->u.array.values[i]));
}
return jansson_array;
} else {
json_t *jansson_object = json_object();
for (size_t i = 0; i < val->u.object.len; i++) {
json_object_set_new(jansson_object, val->u.object.keys[i], yajl_to_json(val->u.object.values[i]));
}
return jansson_object;
}
return NULL;
}

/**
* json_array_to_struct This function extracts keys and values and stores it in struct
* Input: json_t
Expand Down
2 changes: 0 additions & 2 deletions src/ocispec/json_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ int append_json_map_string_string (json_map_string_string *map, const char *key,

char *json_marshal_string (const char *str, size_t length, const struct parser_context *ctx, parser_error *err);

json_t *yajl_to_json(yajl_val val);

typedef struct
{
json_t * values;
Expand Down

0 comments on commit 6d1252a

Please sign in to comment.