Skip to content

broken from_json implementation for pair and tuple  #707

Closed

Description

@theodelrieu

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)...);
}

Activity

  1. nlohmann commented on Aug 22, 2017

    @nlohmann
    Owner

    Can you open a PR?

  2. theodelrieu commented on Aug 22, 2017

    @theodelrieu
    ContributorAuthor

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

  3. added 2 commits that reference this issue on Aug 22, 2017
    15c01a8
    bb1b4c9
  4. added this to the Release 3.0.0 milestone on Aug 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions