|
|
@ -17,8 +17,8 @@ uint8_t is_json_suffix(const char *file_name) { // whether file name end with `. |
|
|
|
return FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
char* to_json(const char *content) { // convert JSON / TOML / YAML to json format (if failed -> return NULL)
|
|
|
|
const char *json_string = to_json_rust(content); // convert to json format
|
|
|
|
char* to_json(const char *content) { // convert JSON / TOML / YAML to json format (failed -> NULL)
|
|
|
|
const char *json_string = to_json_ffi(content); // convert to json format
|
|
|
|
char *json_content = strdup(json_string); // load string into owner heap
|
|
|
|
free_rust_string(json_string); // free rust string
|
|
|
|
if (strlen(json_content) == 0) { // empty string -> convert error
|
|
|
@ -30,6 +30,7 @@ char* to_json(const char *content) { // convert JSON / TOML / YAML to json forma |
|
|
|
return json_content; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cJSON* json_field_get(cJSON *entry, const char *key) { // fetch key from json map (create when key not exist)
|
|
|
|
cJSON *sub = entry->child; |
|
|
|
while (sub != NULL) { // traverse all keys
|
|
|
|