Skip to content

free functions for explicit objects and arrays in initializer lists #8

@nlohmann

Description

@nlohmann

Currently,

{{"a","b"},{"c","d"}}

will be treated as object, and there is no way to express it as array of two arrays with two strings each.

As tgockel points out:

I can't say it's a great solution, but in JSON Voorhees, I went with free functions called array and object to disambiguate the initializer_list syntax. It also solves the issue of {} ambiguously meaning an empty object or empty array (and accidentally making an array when given string_views or something).

Such free functions could solve the above problem:

{array({"a","b"}), array({"c","d"})}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions