pub fn serialize_argument<T: Serialize>(arg: &T) -> ValueExpand description
Serializes an argument for Playwright’s evaluateExpression method.
This is the main entry point for serializing arguments. It wraps the serialized value with the required “value” and “handles” fields.
§Arguments
arg- A value that implementsserde::Serializeor aserde_json::Value
§Returns
A JSON object with “value” and “handles” fields in Playwright’s format:
{
"value": { /* serialized value */ },
"handles": []
}§Examples
use playwright_rs::protocol::serialize_argument;
use serde_json::json;
// String argument
let arg = serialize_argument(&json!("hello"));
// Returns: {"value": {"s": "hello"}, "handles": []}
// Number argument
let arg = serialize_argument(&json!(42));
// Returns: {"value": {"n": 42}, "handles": []}
// Object argument
let arg = serialize_argument(&json!({"name": "test"}));
// Returns: {"value": {"o": [{"k": "name", "v": {"s": "test"}}], "id": 0}, "handles": []}