How to grab a JSON file and decode into C++ ? read the Json file in C++

Asked

Viewed 802 times

1

I have a file JSON with employee data and wish to read this file in C++ to pass para a flash drive and export this file, how to proceed? Follows file JSON:

":"Alexandre N. da C.Neves","ID":"213","PIS":"00000000","Time":1456229448}...

and the program in C++ more or less like this:

typedef struct  funcionario // struct com 100 elementos
{
    char CodBarras[11];
    char BioDados[512];
    char Passwd[11];
    char MiFareDado[21];
    char Nome[53];
    char ID[11];
    char PIS[13];
    char Aux[5];
    long int Tempo;
}functionaries[100];   // array para rodar essa struct 100x 

the program has to load the JSON file and load into Struct.

thanks in advance

  • Are you sure that’s not C?

  • this is C but I need to take the JSON file, and load this Struct in C. ie read the JSON file.

  • Is that you wrote in the title, in the tags and in the description "C++" and not "C".

  • 2

    https://github.com/open-source-parsers/jsoncpp

  • Can you use/compile a little C++, or are you required to have the code entirely in C? If it is 100% in C it will take a lot more work; using C++, you can use JSONCPP as @Luizvieira mentioned, to decode into a Json object::Value, and then popular your struct from it.

  • Solved your doubt?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.