Browse Source

fix: update to_json ffi

dev
Dnomd343 2 years ago
parent
commit
2678e06c64
  1. 5
      src/common/json.c

5
src/common/json.c

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

Loading…
Cancel
Save