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

broken from_json implementation for pair and tuple #707

Closed
theodelrieu opened this issue Aug 22, 2017 · 2 comments
Closed

broken from_json implementation for pair and tuple #707

theodelrieu opened this issue Aug 22, 2017 · 2 comments
Assignees
Milestone

Comments

@theodelrieu
Copy link
Contributor

I just realized that I introduced a bug in the develop branch.

The tests pass, because I forgot to add a test that retrieves a pair and a tuple...
That's really shameful, but luckily we haven't released yet.

// no need for variadic here by the way
template<typename BasicJsonType, typename... Args>
void from_json(const BasicJsonType& j, std::pair<Args...>& p)
{
    // broken, must use at().get<>()
    p = {j.at(0), j.at(1)};
}

template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence<Idx...>)
{
    // same thing here
    t = std::make_tuple(j.at(Idx)...);
}
@nlohmann
Copy link
Owner

Can you open a PR?

@theodelrieu
Copy link
Contributor Author

Should not take really long, I'm on it.

theodelrieu added a commit to theodelrieu/json that referenced this issue Aug 22, 2017
theodelrieu added a commit to theodelrieu/json that referenced this issue Aug 23, 2017
@nlohmann nlohmann added this to the Release 3.0.0 milestone Aug 24, 2017
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