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

What is the best way to parse vec3s into glm::vec3 #1891

Closed
shrikky opened this issue Jan 6, 2020 · 4 comments
Closed

What is the best way to parse vec3s into glm::vec3 #1891

shrikky opened this issue Jan 6, 2020 · 4 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@shrikky
Copy link

shrikky commented Jan 6, 2020

I tried the following, but it didn't work.

void from_json(const json& j, glm::vec3& vec)
{
	j.at("x").get_to(vec.x);
	j.at("y").get_to(vec.y);
	j.at("z").get_to(vec.z);
}

Please help me out,
thank you :)

@nlohmann
Copy link
Owner

nlohmann commented Jan 7, 2020

You need to define the from_json function in the same namespace as the type (see the README), so the following should work:

namespace glm
{

void from_json(const json& j, vec3& vec)
{
	j.at("x").get_to(vec.x);
	j.at("y").get_to(vec.y);
	j.at("z").get_to(vec.z);
}

}

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Jan 7, 2020
@shrikky
Copy link
Author

shrikky commented Jan 7, 2020

that worked, I completely overlooked that. thank you very much nlohmann :)

These questions would definitely help others as well, I will leave it to you to manage labels.

@shrikky shrikky closed this as completed Jan 7, 2020
@shrikky shrikky reopened this Jan 7, 2020
@nlohmann
Copy link
Owner

nlohmann commented Jan 7, 2020

Can I close the issue?

@shrikky
Copy link
Author

shrikky commented Jan 7, 2020

Yes absolutely. Thank you.

@nlohmann nlohmann closed this as completed Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants