I have a JSON File with database environment configuration called env-config.json like this:
{
"LATEST":{
"DB_DATABASE":"databasename",
"DB_HOST":"hosturl",
"DB_PORT":"3306",
"DB_USER":"root",
"POOL_MAX":1
},
"PROD":{
"DB_DATABASE":"databasename",
"DB_HOST":"hosturl",
"DB_PORT":"3306",
"DB_USER":"root",
"POOL_MAX":1
}
}
is in the root of source of a c++ project
so i want to easy touch that config in a json format but use it from my compiled c++ code for example
when the program is running query to the system what environment is, like
system.getEnvironment()
system says "PROD"
in that moment call to that JSON file and extract the info to use in the program.
the problem is that i need a method to distribute the json together with the final executable i can not have the binary and json file in separately files.
i try with:
file (STRINGS "env-config.json" CONFIG)
add_definitions (-DENV_CONFIG=${CONFIG})
and after that use that string in the program, but the problem is that the cmake crash because all the scapes from the json, yes i can put the json in string format with a lot of \n and scapes, but i will lose the json format readably.
So is possible for example have my json file intact in json format and in build time cmake convert it to string and after that use
file (STRINGS "env-config.json" CONFIG)
add_definitions (-DENV_CONFIG=${CONFIG})
or if that is so complicated because the JSON format
is possible use a properties file like java
db-${env}.properties
with this content
db.database.name = mydatabasename
db.database.url = myurl
db.database.user = root
db.database.password = root
and include it together inside the executable like in a MAP inside config class or struct
Thanks so much!
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)