Skip to content

Cannot load json file properly #759

Description

@PowerOfCreation

I couldn't find any example nor documentation on how to load a json file properly. I did it doing so:
ifstream myfile(p.path());

json j;
j << myfile;
cout << j.at(0) << endl;
cout << j[0] << endl;

Neither of those variants do work. I can compile it but I get the error cannot use at() with object and same with the [] operator. Only with a iterator I can actually access my values:
for (json::iterator it = j.begin(); it != j.end(); ++it)
But I can't access the subvalues in any way yet as there are no examples or documentations avaiable.
I tried it in many ways:

json j;
j << myfile;
for (json::iterator it = j.begin(); it != j.end(); ++it) 
{
            json k;
            k << it;
            k << it.value();
...

Are there any examples how to actually load a json file properly or am I doing something wrong?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions