1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Canonical Protobuf-JSON mapping for OxiProto.
//!
//! This crate implements the [canonical Protobuf-JSON spec] for
//! [`prost_reflect::DynamicMessage`]:
//!
//! - Field names serialized as **camelCase** by default
//! (`preserve_proto_field_names(true)` keeps the original names).
//! - `int64`/`uint64` encoded as **JSON strings** to preserve precision.
//! - `bytes` fields encoded as **base64** (RFC 4648 §4, standard alphabet
//! with padding).
//! - `google.protobuf.Timestamp` ↔ RFC 3339 string, e.g.
//! `"2023-11-14T22:13:20Z"`.
//! - `google.protobuf.Duration` ↔ decimal-seconds string, e.g. `"1.5s"`.
//! - Enum values serialized as **name strings**; configurable to emit numbers.
//! - `repeated` → JSON array; `map<K,V>` → JSON object.
//! - Default scalar values **omitted** unless `always_print_fields(true)`.
//!
//! [canonical Protobuf-JSON spec]: https://protobuf.dev/programming-guides/proto3/#json
//!
//! ## M5 Deferred items
//!
//! The following items are **not yet implemented** and are slated for a future
//! milestone:
//!
//! - `google.protobuf.Any` — type-URL resolution requires a live
//! [`prost_reflect::DescriptorPool`] with the target message registered.
//! Currently serialized as an empty object `{}`.
//! - Infinite `f32`/`f64` as strings — the spec requires emitting
//! `"Infinity"`, `"-Infinity"`, and `"NaN"`. Currently emitted as `null`.
//! - `google.protobuf.Struct`, `google.protobuf.Value`,
//! `google.protobuf.ListValue` — treated as regular messages for now.
//! - `google.protobuf.FieldMask` — treated as a regular message.
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use oxiproto_json::{to_json, from_json, JsonCodec};
//! use prost_reflect::{DynamicMessage, MessageDescriptor};
//!
//! # fn example(msg: &DynamicMessage, desc: &MessageDescriptor) {
//! let codec = JsonCodec::default();
//! let json_value = to_json(msg, &codec);
//!
//! let rebuilt = from_json(&json_value, desc, &codec).expect("round-trip");
//! # }
//! ```
pub use JsonCodec;
pub use ;
pub use to_json;