Enhanced config JSON serialization

Updated the configuration dump function to serialize argument-value pairs into more detailed JSON objects. This now includes the argument's name, data type, value, and dimensions instead of just the value as a string. This richer output format allows for enhanced configuration clarity and downstream data processing. Improved type information and dimension data support handling various data types and array structures without information loss or ambiguity.
This commit is contained in:
Kumi 2024-02-05 13:32:52 +01:00
parent 83f3221162
commit 5f323fea96
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -278,9 +278,23 @@ void dumpConfig(Config2HDFattr_t *config, size_t size) {
ii_oupargs++;
}
// Turn argument-value pairs to JSON objects
/*
string arg;
H5std_string Name;
H5::DataType dType;
void *Value;
hsize_t dim;
std::cout << "\"" << arg << "\": \"";
*/
// Turn arguments to JSON objects
std::cout << "\"" << arg << "\": {";
std::cout << "\"name\": \"" << config[i].Name << "\", ";
std::cout << "\"type\": \"" << typeid(config[i]).name() << "\", ";
std::cout << "\"value\": \"";
// Need to cast void* data pointer to the correct type
// TODO: Do we lose precision here?
@ -294,7 +308,11 @@ void dumpConfig(Config2HDFattr_t *config, size_t size) {
std::cout << static_cast<char *>(config[i].Value);
}
std::cout << "\"";
std::cout << "\", ";
std::cout << "\"dim\": " << config[i].dim;
std::cout << "}";
if (i < size - 1) {
std::cout << ",";