(
state: &mut State<'gc>,
args: Vec<Value<'gc>>,
)
| 28 | } |
| 29 | |
| 30 | fn serde_from_str<'gc>( |
| 31 | state: &mut State<'gc>, |
| 32 | args: Vec<Value<'gc>>, |
| 33 | ) -> Result<Value<'gc>, VmError> { |
| 34 | if args.is_empty() || args.len() > 1 { |
| 35 | return Err(VmError::RuntimeError( |
| 36 | "from_str() takes exactly 1 argument".into(), |
| 37 | )); |
| 38 | } |
| 39 | |
| 40 | let json_str = string_arg!(&args, 0, "from_str")?; |
| 41 | |
| 42 | // Parse JSON string into serde_json::Value |
| 43 | let parsed = serde_json::from_str(json_str.to_str().unwrap()) |
| 44 | .map_err(|e| VmError::RuntimeError(format!("Failed to parse JSON: {}", e)))?; |
| 45 | |
| 46 | // Convert serde_json::Value to AIScript Value |
| 47 | Ok(Value::from_serde_value(state.get_context(), &parsed)) |
| 48 | } |
| 49 | |
| 50 | fn serde_to_str<'gc>(state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> { |
| 51 | let (positional, keyword) = extract_keyword_args(&args)?; |
nothing calls this directly
no test coverage detected