You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a student project, we are currently trying to parse an input file in *.json format with keys containing underscores. This is tested using the code example presented below, where we run into the following assert:
terminate called after throwing an instance of 'dealii::ParameterHandler::ExcEntryUndeclared'what():
--------------------------------------------------------
An error occurred in line <1234> of file </home/magdalena/code/external_libs/dealii/source/base/parameter_handler.cc>in function
void dealii::ParameterHandler::set(const std::string&, const std::string&)
The violated condition was:
false
Additional information:
You can't ask for entry <testAborted (core dumped)
When we switch to *.prm format, everything works as expected. We assume that there is an inconsistency in mangling/demangling between boost and deal.II for *.json files (and maybe also for *.xml files (?)). At the moment I don't have a solution for a quick fix, but since I think this might be a common use case, I wanted to report this issue. We could at least add an appropriate assert. I will look into it asap.
#include<deal.II/base/parameter_handler.h>
#include<fstream>
#include<iostream>usingnamespacedealii;intmain(int argc, char *argv[])
{
ParameterHandler prm;
double test_0 = 0;
// test if underscore can be parsed
prm.add_parameter("test_0", test_0);
std::ifstream file;
file.open(argv[1]);
prm.parse_input_from_json(file);
prm.print_parameters(std::cout, ParameterHandler::OutputStyle::ShortJSON);
return0;
}
tested with the file test.json
{
"test_0": "1"
}
The text was updated successfully, but these errors were encountered:
mschreter
changed the title
ParameterHandler: Problem with parsing keys containing underscores in *.json files
ParameterHandler: *.json files with keys containing underscores cannot be parsed
Jan 10, 2024
As far as I remember, for xml the parameter names need to be mangled. Internally, we use the same xml algorithms internally to create the json format, so for json those had to be mangled as well.
Problem description
In a student project, we are currently trying to parse an input file in
*.json
format with keys containing underscores. This is tested using the code example presented below, where we run into the following assert:When we switch to
*.prm
format, everything works as expected. We assume that there is an inconsistency in mangling/demangling between boost and deal.II for*.json
files (and maybe also for*.xml
files (?)). At the moment I don't have a solution for a quick fix, but since I think this might be a common use case, I wanted to report this issue. We could at least add an appropriate assert. I will look into it asap.@j-brotz FYI
Test code
tested with the file
test.json
The text was updated successfully, but these errors were encountered: