A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
Loading...
Searching...
No Matches
json.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors.
2
3#ifndef A11_DATA_JSON_H_
4#define A11_DATA_JSON_H_
5
6#include <string>
7#include <string_view>
8
9#include <absl/status/statusor.h>
10#include <nlohmann/json_fwd.hpp>
11
12#include "a11/data/types.h"
13
14namespace a11::data {
15
16// JSON encoding used by A11's HTTP/SSE transports. Byte strings are base64
17// encoded, timestamps use RFC 3339, and omitted/default fields accepted by the
18// Python Pydantic models are emitted explicitly where that removes union
19// ambiguity.
20absl::StatusOr<nlohmann::json> WireMessageToJsonValue(
21 const WireMessage& message);
22absl::StatusOr<std::string> WireMessageToJson(const WireMessage& message);
23absl::StatusOr<WireMessage> WireMessageFromJsonValue(
24 const nlohmann::json& value);
25absl::StatusOr<WireMessage> WireMessageFromJson(std::string_view encoded);
26
27} // namespace a11::data
28
29#endif // A11_DATA_JSON_H_
Definition json.cc:22
absl::StatusOr< WireMessage > WireMessageFromJsonValue(const Json &value)
Definition json.cc:476
absl::StatusOr< WireMessage > WireMessageFromJson(std::string_view encoded)
Definition json.cc:529
absl::StatusOr< std::string > WireMessageToJson(const WireMessage &message)
Definition json.cc:461
absl::StatusOr< Json > WireMessageToJsonValue(const WireMessage &message)
Definition json.cc:431
Future< T > SubmitWithCancellationHook(absl::AnyInvocable< absl::StatusOr< T >() && > work, std::function< void()> cancellation_hook, thread::TreeOptions tree_options)
Run work on A11's fiber pool with application-specific cancellation.
Definition executor.h:30
A11's core wire value types: chunks, node fragments and messages.