-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
read in .json file yields strange sizes #487
Comments
Ok I narrowed down the problem. My input looks as follows, and apparently only the imgHeight, imgWidt and objectsare counted as entries. How can I then access the inner elements in the json container?
|
You can try |
does not work. I get 0% returned |
What gives |
thank you for your quick reply! it yields the content of the entire file |
Of what do you want to get the size then? |
cuz I want to access the range of numeric tuples in the inner most element and write them into a new json file |
I do not understand your problem. If the input file is the one of your second comment and you want to have the number of elements in the |
well for me it does not, it gives 1%. I somehow need a way to access the tuples in the inner array |
How can this function return a percentage? What array do you mean? I tried to be concrete, but you only told me that it does not work. |
I will try to elaborate, wait a second |
well ok in the shell it showed 1%, in a file it is displayed as 1, which is correct I guess. But the main problem remains: How can I access elements of a json file that are cascaded deep in several layers of arrays, e.g. how can I access in my given file just the number pairs by means of the json-container? |
|
My Psychic Debugging skills (see The Old New Thing) says that you did
at the end of your program, and that because you didn't include "\n", you got the |
Danke Niels und viele Grüße nach Berlin! @gregmarr: No my shell is not the culprit |
Grüße zurück! Does it work now? |
I think so, I will have to further investigate. I am given a messed up json file that I have to clean up and bring into a shape comparable to the one I posted above, so I will see if I can manage |
one last question: I am trying to achieve a similar output format as in my example above, where there are two braces following each other, namely " [ {". But I cannot figure out how to put this in the code in order to get the desired output |
You can use
|
awesome. Thank you so much niels |
Can I close the issue? |
if I am allowed to open up another one in case of further questions, yes ; ) |
Of course :) |
I am trying to read in an .json file into an json object via the overloaded >> operator
I can also write it to another .json file with << which reproduces the same file, as expected.
however, when I try to find out about the size of the json-container, it yields 3, although my file is quite big
json input; i >> input; std::cout << input.size() << input << std::endl;
it gives the correct content but the size is obviously wrong
The text was updated successfully, but these errors were encountered: