Enum cedar_policy_core::entities::JSONValue
source · pub enum JSONValue {
ExprEscape {
__expr: SmolStr,
},
EntityEscape {
__entity: TypeAndId,
},
ExtnEscape {
__extn: FnAndArg,
},
Bool(bool),
Long(i64),
String(SmolStr),
Set(Vec<JSONValue>),
Record(HashMap<SmolStr, JSONValue>),
}
Expand description
The canonical JSON representation of a Cedar value.
Many Cedar values have a natural one-to-one mapping to and from JSON values.
Cedar values of some types, like entity references or extension values,
cannot easily be represented in JSON and thus are represented using the
__expr
, __entity
, or __extn
escapes.
For example, this is the JSON format for attribute values expected by
EntityJsonParser
, when schema-based parsing is not used.
Variants§
ExprEscape
Special JSON object with single reserved “__expr” key:
interpret the following string as a (restricted) Cedar expression.
Some escape (this or the following ones) is necessary for extension
values and entity references, but this __expr
escape could also be
used for any other values.
__expr
is deprecated (starting with the 1.2 release) and will be
removed in favor of __entity
and __extn
, which together cover all of
the use-cases where __expr
would have been necessary.
EntityEscape
Special JSON object with single reserved “__entity” key:
the following item should be a JSON object of the form
{ "type": "xxx", "id": "yyy" }
.
Some escape (this or __expr
, which is deprecated) is necessary for
entity references.
ExtnEscape
Special JSON object with single reserved “__extn” key:
the following item should be a JSON object of the form
{ "fn": "xxx", "arg": "yyy" }
.
Some escape (this or __expr
, which is deprecated) is necessary for
extension values.
Bool(bool)
JSON bool => Cedar bool
Long(i64)
JSON int => Cedar long (64-bit signed integer)
String(SmolStr)
JSON string => Cedar string
Set(Vec<JSONValue>)
JSON list => Cedar set; can contain any JSONValues, even heterogeneously
Record(HashMap<SmolStr, JSONValue>)
JSON object => Cedar record; must have string keys, but values can be any JSONValues, even heterogeneously
Implementations§
source§impl JSONValue
impl JSONValue
sourcepub fn into_expr(self) -> Result<RestrictedExpr, JsonDeserializationError>
pub fn into_expr(self) -> Result<RestrictedExpr, JsonDeserializationError>
Convert this JSONValue into a Cedar “restricted expression”
sourcepub fn from_expr(
expr: BorrowedRestrictedExpr<'_>,
) -> Result<Self, JsonSerializationError>
pub fn from_expr( expr: BorrowedRestrictedExpr<'_>, ) -> Result<Self, JsonSerializationError>
Convert a Cedar “restricted expression” into a JSONValue
.
Trait Implementations§
source§impl<'de> Deserialize<'de> for JSONValue
impl<'de> Deserialize<'de> for JSONValue
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for JSONValue
impl StructuralPartialEq for JSONValue
Auto Trait Implementations§
impl Freeze for JSONValue
impl RefUnwindSafe for JSONValue
impl Send for JSONValue
impl Sync for JSONValue
impl Unpin for JSONValue
impl UnwindSafe for JSONValue
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more