Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ilikenwf opened this issue Apr 24, 2016 · 1 comment
Labels
solution: invalid the issue is not related to the library

Comments

@ilikenwf
Copy link

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;
@ilikenwf
Copy link
Author

Nevermind, I failed to notice an issue on the API that was sending this...it was wrapping up the message in an array.

@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Apr 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants