Loading...
Searching...
No Matches
json.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <string>
#include <bsoncxx/json-fwd.hpp> // IWYU pragma: export
#include <bsoncxx/array/view.hpp>
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/stdx/optional.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
enum class ExtendedJsonMode : std::uint8_t {
k_legacy,
k_canonical,
k_relaxed,
};
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(std::string)
to_json(document::view view, ExtendedJsonMode mode = ExtendedJsonMode::k_legacy);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(std::string)
to_json(array::view view, ExtendedJsonMode mode = ExtendedJsonMode::k_legacy);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(document::value) from_json(stdx::string_view json);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(document::value) operator""_bson(char const* json, size_t len);
} // namespace v_noabi
} // namespace bsoncxx
namespace bsoncxx {
using v_noabi::from_json;
using v_noabi::to_json;
using v_noabi::operator""_bson;
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
#define BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to BSONCXX_ABI_EXPORT_UNSTABLE with BSONCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
json-fwd.hpp
Declares bsoncxx::v_noabi::ExtendedJsonMode.
bsoncxx::v_noabi::array
Declares entities representing a BSON array.
bsoncxx::v_noabi::document
Declares entities representing a BSON document.
bsoncxx::v_noabi::stdx
Declares C++17 standard library polyfills.
bsoncxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
bsoncxx::v_noabi::to_json
std::string to_json(document::view view, ExtendedJsonMode mode=ExtendedJsonMode::k_legacy)
Converts a BSON document to a JSON string, in extended format.
bsoncxx::v_noabi::ExtendedJsonMode
ExtendedJsonMode
An enumeration of the types of Extended JSON that the to_json function accepts.
Definition json.hpp:33
bsoncxx::v_noabi::ExtendedJsonMode::k_relaxed
@ k_relaxed
to produce Relaxed Extended JSON
Definition json.hpp:36
bsoncxx::v_noabi::ExtendedJsonMode::k_legacy
@ k_legacy
to produce Legacy Extended JSON
Definition json.hpp:34
bsoncxx::v_noabi::ExtendedJsonMode::k_canonical
@ k_canonical
to produce Canonical Extended JSON
Definition json.hpp:35
bsoncxx::v_noabi::from_json
document::value from_json(stdx::string_view json)
Constructs a new document::value from the provided JSON text.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
view.hpp
Provides bsoncxx::v_noabi::array::view.
value.hpp
Provides bsoncxx::v_noabi::document::value.
view.hpp
Provides bsoncxx::v_noabi::document::view.
optional.hpp
Provides std::optional-related polyfills for library API usage.