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

Using json Object as value in a map #725

Closed
FATEDx opened this issue Sep 3, 2017 · 5 comments
Closed

Using json Object as value in a map #725

FATEDx opened this issue Sep 3, 2017 · 5 comments

Comments

@FATEDx
Copy link

FATEDx commented Sep 3, 2017

I have a map, that have key string, and json as the value
std::map<std::string, json> mList;
Then,
std::map<std::string, json>::iterator i = mList.at(name);
std::map<std::string, json>::iterator end = mList.end();

When i try to access the iterator, it keep giving me error about
Error C2338 could not find from_json() method in T's namespace

I have no idea what is going on, can someone help?

@nlohmann
Copy link
Owner

nlohmann commented Sep 3, 2017

std::map<std::string, json>::iterator i = mArchetypeList.at(name); calls at which returns a reference and not an iterator. Can you provide a detailed error message?

@nlohmann
Copy link
Owner

nlohmann commented Sep 3, 2017

Can you also provide the code in gameobjectfactory.cpp(334) and maybe some context lines?

@FATEDx
Copy link
Author

FATEDx commented Sep 3, 2017

Oh dear, i found my mistake. Sorry.
I would like to ask if storing all the data in the json object in this manner, will if have any effiency problem?

@nlohmann
Copy link
Owner

nlohmann commented Sep 3, 2017

Under the hood, objects are stored in an std::map. Each value has some overhead (a few pointer), but basically it should not make things too bad.

@FATEDx
Copy link
Author

FATEDx commented Sep 3, 2017

Alright Thank you so much! This is very helpful

@FATEDx FATEDx closed this as completed Sep 3, 2017
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

2 participants