Skip to content

scalar transforms to list #2000

Description

@toohes

code:

	int i = 948;
	json scalar = i;
	std::cout << "<start>\n" << scalar.dump() << "\n<end>\n";
	json record;
	record["scalar"] = scalar;
	std::cout << "<start>\n" << record.dump() << "\n<end>\n";

g++ 7.2 output:

<start>
948
<end>
<start>
{"scalar":948} // ok
<end>

MSVC 2017 with default c++ standard setting and "ISO C++14 Standard (/std:c++14)" output:

<start>
948
<end>
<start>
{"scalar":[948]} // why list?
<end>

Activity

  1. nlohmann commented on Mar 19, 2020

    @nlohmann
    Owner

    Is that the exact code you run or are there some brace initializations somewhere?

  2. toohes commented on Mar 19, 2020

    @toohes
    Author

    it is copypaste.
    i spend some time for war with markdown.

  3. toohes commented on Mar 19, 2020

    @toohes
    Author

    ups. i've found my bug. sorry.

  4. toohes commented on Mar 19, 2020

    @toohes
    Author

    there was wrong typedef

    	typedef vr::jsn::Packet json;

    where

    	class Packet : public detail::json
    		{
    		public:
    			Packet() = default;
    			Packet(Packet const&) = delete;
    			Packet& operator =(Packet&& p) = default;
    			Packet(detail::json&& j)= default;
    		};

    right typedef

    typedef nlohmann::json json;

    has fixed bug.
    nonetheless behavior of gcc and msvc is different.

    remote work so remote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions