Skip to content
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

Get keys from json object #1107

Closed
Radmir2015 opened this issue May 25, 2018 · 11 comments
Closed

Get keys from json object #1107

Radmir2015 opened this issue May 25, 2018 · 11 comments

Comments

@Radmir2015
Copy link

Is it possible to get all keys from json object (like on picture)?
screenshot_181
screenshot_182

@nlohmann
Copy link
Owner

You may want to have a look at the items() function.

@Radmir2015
Copy link
Author

Thank you so much. I already tried this method and it did not work for me, because I forgot to add (), I thought that key and value are properties.
And now I realized that this is a function and it returns a json-object.

@nlohmann
Copy link
Owner

@Radmir2015 Can we close this issue or do you need further assistance?

@Radmir2015
Copy link
Author

Yes, of course. Thanks.

@arpit279
Copy link

when I am trying to use the item method, I am facing this error:-
‘using json = using json = class nlohmann::basic_json<> {aka class nlohmann::basic_json<>}’ has no member named ‘items’

@nlohmann
Copy link
Owner

Which version are you using? items was only introduced in a later version. Before, the function was called iterator_proxy.

@arpit279
Copy link

what version are you asking ? if the library then it is 2.1.1-1.1, and does the function iterator_proxy works same as items ?

@nlohmann
Copy link
Owner

Basically yes, but you should consider updating the library - there have been multiple bug fixes and performance improvements since.

@arpit279
Copy link

Can you please guide me in updating, Since I am new to this things, I am still learning.
I tried the sudo apt-get install --only-upgrade nlohmann-json-dev command, but it shows already a newest version. please help.

@nlohmann
Copy link
Owner

This seems to be related to #1438. I do not know who's in charge of that package.

You could also download the json.hpp header here and adjust your include directory to use that header rather than the outdated version.

@arpit279
Copy link

Thank you so much,
Now my code is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants