Skip to content

very basic: fetching string value/content without quotes #853

Description

@rnsanchez

This is kind of a usage issue and not a bug/feature request. I could be overlooking something trivial as I am very new to the library; if this is the case, please point in the right direcion/documentation.

  • What is the issue you have?

When printing/using a value from a string element, the string is quoted:

$ ./test 
"value"
  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
    #include <iostream>
    #include "json.hpp"
    using json = nlohmann::json;
    int main(int argc, char *argv[])
    {
        json j = R"({"one": "value"})"_json;
        std::cout << j["one"] << '\n';
    }
  • What is the expected behavior?

Printing/fetching value as opposed to "value".

I understand that this could be a simple matter of picking out a substring, but searching in the documentation and existing issues (closed and open), I didn't find an idiomatic way of simply extracting the original string (no quotes as quotes are not escaped in the JSON blob).

GCC (7.2.0).

  • Did you use a released version of the library or the version from the develop branch?

Git master, cc937de

Activity

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions