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

The only place A11 hands text or bytes to nlohmann, or asks for them. 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, or explains why it is not JSON.
 
bool a11::IsValidUtf8 (std::string_view text)
 Whether text is valid 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.
 
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< Json > a11::UnpackMsgpack (std::string_view encoded, std::string_view what)
 Decodes MessagePack bytes, or explains why they are not.
 

Detailed Description

The only place A11 hands text or bytes to nlohmann, or asks for them.

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.