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

JSONCONS_N_MEMBER_NAME_TRAITS does not compile #263

Closed
alokpr opened this issue Aug 11, 2020 · 2 comments
Closed

JSONCONS_N_MEMBER_NAME_TRAITS does not compile #263

alokpr opened this issue Aug 11, 2020 · 2 comments

Comments

@alokpr
Copy link

alokpr commented Aug 11, 2020

JSONCONS_N_MEMBER_NAME_TRAITS produces compile error. It also does not have any test coverage.

JSONCONS_ALL_MEMBER_NAME_TRAITS works fine.

struct Person {
  std::string name;
  std::string surname;
};

JSONCONS_N_MEMBER_NAME_TRAITS(Person, 1, (name, "n"), (surname, "sn"))

int main() {
  std::string data = R"({"n":"Rod"})";
  auto person = jsoncons::decode_json<Person>(data);

  std::string s;
  jsoncons::encode_json_pretty(person, s);
  std::cout << s << "\n";
}

FAILED:

jsoncons-0.155.0/include/jsoncons/json_traits_macros.hpp:307:114: error: ‘name_str’ is not a member of ‘jsoncons::json_traits_macro_names<char, Person>’
   {json_traits_helper<Json>::set_optional_json_member(json_traits_macro_names<char_type,value_type>::Member##_str(char_type{}), aval.Member, ajson);}
  • Compiler: gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
  • Architecture: x86_64
  • Operating system: Ubuntu 18.04

**What jsoncons library version
0.155.0

@alokpr alokpr added the Bug label Aug 11, 2020
danielaparker added a commit that referenced this issue Aug 12, 2020
@danielaparker
Copy link
Owner

Thanks for reporting this, fixed on master, and your test case added.

danielaparker added a commit that referenced this issue Aug 12, 2020
danielaparker added a commit that referenced this issue Aug 12, 2020
@alokpr
Copy link
Author

alokpr commented Aug 12, 2020

Thanks a lot for the quick fix!

Great project BTW. I finally decided on jsoncons after evaluating quite a few json libraries out there.

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