JsonConfig: refactor to get rid of data-ffjson_*

This commit is contained in:
李通洲
2023-03-15 15:24:40 +08:00
parent 5f52c64d4d
commit dca9ce4b2d
37 changed files with 463 additions and 364 deletions
+16 -13
View File
@@ -89,7 +89,7 @@ void ffDestroyBluetoothOptions(FFBluetoothOptions* options)
}
#ifdef FF_HAVE_JSONC
bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module)
bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_object* module)
{
if (strcasecmp(type, FF_BLUETOOTH_MODULE_NAME) != 0)
return false;
@@ -97,21 +97,24 @@ bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCDat
FFBluetoothOptions __attribute__((__cleanup__(ffDestroyBluetoothOptions))) options;
ffInitBluetoothOptions(&options);
FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val)
if (module)
{
if (strcasecmp(key, "type") == 0)
continue;
if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs))
continue;
if (strcasecmp(key, "showConnected") == 0)
json_object_object_foreach(module, key, val)
{
options.showDisconnected = data->ffjson_object_get_boolean(val);
continue;
}
if (strcasecmp(key, "type") == 0)
continue;
ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
continue;
if (strcasecmp(key, "showConnected") == 0)
{
options.showDisconnected = json_object_get_boolean(val);
continue;
}
ffPrintError(instance, FF_BLUETOOTH_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
}
}
ffPrintBluetooth(instance, &options);
+2 -2
View File
@@ -8,6 +8,6 @@ bool ffParseBluetoothCommandOptions(FFBluetoothOptions* options, const char* key
void ffDestroyBluetoothOptions(FFBluetoothOptions* options);
#ifdef FF_HAVE_JSONC
#include "common/config.h"
bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module);
#include "common/jsonconfig.h"
bool ffParseBluetoothJsonObject(FFinstance* instance, const char* type, json_object* module);
#endif