MCPcopy Create free account
hub / github.com/cedar-policy/cedar-java / get_json_schema_internal

Function get_json_schema_internal

CedarJavaFFI/src/interface.rs:1126–1150  ·  view source on GitHub ↗
(
    env: &mut JNIEnv<'a>,
    cedar_schema_jstr: JString<'a>,
)

Source from the content-addressed store, hash-verified

1124}
1125
1126pub fn get_json_schema_internal<'a>(
1127 env: &mut JNIEnv<'a>,
1128 cedar_schema_jstr: JString<'a>,
1129) -> Result<JValueOwned<'a>> {
1130 let schema_jstr = env.get_string(&cedar_schema_jstr)?;
1131 let schema_str = schema_jstr.to_str()?;
1132 let cedar_schema_str = FFISchema::Cedar(schema_str.into());
1133 let json_format = schema_to_json(cedar_schema_str);
1134
1135 match json_format {
1136 SchemaToJsonAnswer::Success { json, warnings: _ } => {
1137 let json_pretty = serde_json::to_string_pretty(&json)?;
1138 let jstr = env.new_string(&json_pretty)?;
1139 Ok(JValueGen::Object(JObject::from(jstr)).into())
1140 }
1141 SchemaToJsonAnswer::Failure { errors } => {
1142 let joined_errors = errors
1143 .iter()
1144 .map(|e| e.message.clone())
1145 .collect::<Vec<_>>()
1146 .join("; ");
1147 Err(joined_errors.into())
1148 }
1149 }
1150}
1151
1152#[cfg(test)]
1153pub(crate) mod jvm_based_tests {

Calls 2

ObjectInterface · 0.85
iterMethod · 0.80