Skip to content

.get<std::string>() works for non spaced string but returns as array for spaced/longer strings #236

Closed
@ilikenwf

Description

I'm not sure if this is the expected behavior or not, but seeing as how the json below isn't really returning the "message" as an array, I'm confused as to why I'm having to use [0] to select it...

Assuming the json below:

    {
        "status": "failure",
        "message": "This is a spaced string."
    }

Works:

    std::string status = j["status"].get<std::string>();
    cout << status;

Doesn't work:

   std::string message = j["message"].get<std::string>();
   cout << message;

Works:

   std::string message = j["message"][0].get<std::string>();
   cout << message;

Metadata

Assignees

No one assigned

    Labels

    solution: invalidthe issue is not related to the library

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions