Copying a glz::json_t
wraps the value in an extra array.
#930
Replies: 4 comments
-
I cannot reproduce it with a simplified code… Let me see if this is a bug on my side. |
Beta Was this translation helpful? Give feedback.
-
Minimal reproducible codeWhen you copy(-construct) a std::string output;
glz::write_json(glz::json_t{*(glz::read_json<glz::json_t>("{}"))}, output);
// {} → [{}] |
Beta Was this translation helpful? Give feedback.
-
Thanks for bringing up this issue. I added a test case for it on this pull request: #897. The weird thing is that this only occurs on GCC, and not MSVC or Clang. I'm not yet sure which compiler is correct. Maybe GCC is wrong? I think GCC is seeing this as an initializer list rather than a copy construction. |
Beta Was this translation helpful? Give feedback.
-
I have not been able to figure out a way to fix GCC in this case. I am fairly convinced that this is a GCC bug, because it should select the constructor that takes the type directly over the initializer list version. But, GCC is instead choosing to use the initializer list constructor even though no additional braces were added to make it an initializer list. The cross platform solution is to use parentheses glz::write_json(glz::json_t(*(glz::read_json<glz::json_t>("{}"))), output); I'm going to convert this issue into a discussion for future reference. If you wanted, you could report this bug to GCC. |
Beta Was this translation helpful? Give feedback.
-
Bug
when the
input_string
(astd::string_view
with.remove_prefix(…)
applied) is “{"type":"A","service_set_identifier":"","passphrase":""}
”, the parsedglz::json_t
ends up with “[{"passphrase":"","service_set_identifier":"","type":"A"}]
”, the original value wrapped in an array.I’ve just stumbled upon this; not sure if this is reproducible.
Beta Was this translation helpful? Give feedback.
All reactions