Skip to content

STL containers are always serialized to a nested array like [[1,2,3]] #1013

@fred777

Description

@fred777

Bug Report

I'm using the single-header json.hpp (v3.1.1) and I am struggling with serializing stl containers:

auto tojson = nlohmann::json{ std::forward_list<double>{1,2,3} };
cout << tojson;

Expected: [1,2,3]
Got instead: [[1,2,3]]

It's the same for other STL containers like vector, list, initializer_list, ...

Did I miss something?

Compiler: Visual C++ 2017 (v15.6.1)
OS: Windows 10 x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions