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

How to add json objects to a map? #432

Closed
davidshen84 opened this issue Jan 20, 2017 · 6 comments
Closed

How to add json objects to a map? #432

davidshen84 opened this issue Jan 20, 2017 · 6 comments

Comments

@davidshen84
Copy link

I have an array of json objects.

[{id: 1...},
     {id: 2...}
     ....
  ]

I want to put each of them into a map<string, ?> for easy look up.

But I have no idea what to use for ?.

@nlohmann
Copy link
Owner

That entirely depends on your stored JSON objects. If all object values are integers, you can use std::map<std::string, int> - but once you are not sure, you need to create a container which is basically basic_json.

@davidshen84
Copy link
Author

davidshen84 commented Jan 20, 2017 via email

@nlohmann
Copy link
Owner

Yes, you need to fill the template parameters - can you try json?

@davidshen84
Copy link
Author

davidshen84 commented Jan 21, 2017 via email

@nlohmann
Copy link
Owner

You do not need to fill parameters if you use json- it is just a specialization for basic_json. Can you please provide a detailed error message?

@davidshen84
Copy link
Author

davidshen84 commented Jan 22, 2017 via email

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

No branches or pull requests

2 participants