dpp/data_contract/conversion/json/v0/mod.rs
1use crate::version::PlatformVersion;
2use crate::ProtocolError;
3use serde_json::Value as JsonValue;
4
5/// JSON deserialization for `DataContract` with an explicit validation flag.
6///
7/// `from_json(value, full_validation, pv)` is the single entry point: pass
8/// `true` on trust boundaries (SDK ingest, gRPC handlers, fixture loaders) to
9/// run full schema validation, and `false` to reconstruct already-trusted data
10/// (e.g. storage reads) without re-validating it.
11///
12/// For *serialization*, use canonical `JsonConvertible::to_json` /
13/// `serde_json::to_value(&data_contract)` directly — there is no validation
14/// dimension to writing.
15pub trait DataContractJsonConversionMethodsV0 {
16 /// Deserialize from JSON, running full schema validation when
17 /// `full_validation` is `true`.
18 fn from_json(
19 json_value: JsonValue,
20 full_validation: bool,
21 platform_version: &PlatformVersion,
22 ) -> Result<Self, ProtocolError>
23 where
24 Self: Sized;
25}