| 835 | } |
| 836 | |
| 837 | fn to_json_internal<'a>(env: &mut JNIEnv<'a>, policy_jstr: JString<'a>) -> Result<JValueOwned<'a>> { |
| 838 | if policy_jstr.is_null() { |
| 839 | raise_npe(env) |
| 840 | } else { |
| 841 | let policy_jstring = env.get_string(&policy_jstr)?; |
| 842 | let policy_string = String::from(policy_jstring); |
| 843 | let policy = Policy::from_str(&policy_string)?; |
| 844 | let policy_json = serde_json::to_string(&policy.to_json().unwrap())?; |
| 845 | Ok(JValueGen::Object(env.new_string(&policy_json)?.into())) |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | #[jni_fn("com.cedarpolicy.model.policy.Policy")] |
| 850 | pub fn policyEffectJni<'a>(mut env: JNIEnv<'a>, _: JClass, policy_jstr: JString<'a>) -> jvalue { |