A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
json_codec.h File Reference

Status-returning JSON and MessagePack codecs. More...

#include <string>
#include <string_view>
#include <absl/status/statusor.h>
#include <nlohmann/json.hpp>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  a11
 

Functions

absl::StatusOr< Json > a11::ParseJson (std::string_view encoded, std::string_view what)
 Parses JSON text, returning a status for invalid input.
 
absl::StatusOr< nlohmann::ordered_json > a11::ParseOrderedJson (std::string_view encoded, std::string_view what)
 Parse host fields retaining their declared insertion order.
 
bool a11::IsValidUtf8 (std::string_view text)
 Whether text is valid strict UTF-8.
 
const nlohmann::json * a11::FindUnencodableString (const nlohmann::json &value)
 The first string inside value that is not valid UTF-8, or nullptr.
 
absl::StatusOr< std::string > a11::DumpJson (const nlohmann::json &value, std::string_view what)
 Serializes value, rejecting strings that are not valid UTF-8.
 
absl::StatusOr< std::string > a11::DumpOrderedJson (const nlohmann::ordered_json &value, std::string_view what)
 Serialize host fields retaining their declared insertion order.
 
std::string a11::DumpJsonLossy (const nlohmann::json &value)
 Serializes value, replacing anything that is not valid UTF-8.
 
absl::StatusOr< std::string > a11::PackMsgpack (const nlohmann::json &value, std::string_view what)
 Encodes value as MessagePack, or says why it cannot be.
 
absl::StatusOr< std::string > a11::PackOrderedMsgpack (const nlohmann::ordered_json &value, std::string_view what)
 Encode host fields retaining their declared insertion order.
 
absl::StatusOr< Json > a11::UnpackMsgpack (std::string_view encoded, std::string_view what)
 Decodes MessagePack bytes, or explains why they are not.
 

Detailed Description

Status-returning JSON and MessagePack codecs.

These functions convert untrusted JSON and MessagePack input into status errors. json_codec.cc enables exceptions for the nlohmann operations that have no non-throwing overload; other A11 translation units remain -fno-exceptions.