mirror of
https://github.com/nlohmann/json.git
synced 2026-10-22 14:08:13 +00:00
deploy: 4155e2938f
This commit is contained in:
1 parent
be4d0a6f4b
commit
90f0c9d411
714 files changed
+22067
-622
No files matched your search
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <nlohmann/json_view.hpp>
|
||||
|
||||
using json_document = nlohmann::json_document;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::boolalpha;
|
||||
|
||||
std::string text = R"({"a": 1})";
|
||||
json_document doc = json_document::parse(text);
|
||||
|
||||
// source() is the parsed text, whether borrowed or owned
|
||||
std::cout << (doc.source().size() == text.size()) << '\n';
|
||||
std::cout << std::string(doc.source().data(), doc.source().size()) << '\n';
|
||||
|
||||
// for a borrowed document, source() points right into the caller's buffer
|
||||
std::cout << (doc.source().data() == text.data()) << '\n';
|
||||
}
|
||||
Reference in new issue
Block a user