1
I’m having problems inflating a struct using a JSON file, in fact I don’t know how to do it, I’ve been researching about the Jsoncpp library, but I was not successful.
Follow a simple example of my code:
#include <iostream>
using namespace std;
struct Itens{
int id, tipo, valor;
};
int main() {
funcaoEncherStruct();
return 0;
}
void funcaoEncherStruct(){
//Segue função aqui
}
JSON file:
{
"Itens": {
"Produto1": {
"id": 1,
"tipo": 1,
"valor": 20,
},
"Produto2": {
"id": 2,
"tipo": 3,
"valor": 33,
},
"Produto3": {
"id": 3,
"tipo": 6,
"valor": 60,
}
}
}
I got it, I was able to open my eyes a little bit to it, when I say inflate a struct I say fill it, you know? I tried to compile the code and ran after some solution, but I found some incomplete or more techniques, the " Json::Reader " is not depreciated? It would not be: "Json::Charreaderbuilder", as I parse with this property?
– neto schneider
But there is no way to fill a struct, struct only defines the type of data understand?
– André Giacomini
I understand, I already solved this riddle too, I used another library in which the documentation was more organized, but thanks for the help!
– neto schneider