referrerpolicy=no-referrer-when-downgrade
pub fn retain_initialized_fields(
    json_value: &mut Value,
    keys_to_retain: &[InitializedField<'_>],
    current_root: String,
)
Expand description

Recursively removes keys from provided json_value object, retaining only specified keys.

This function modifies the provided json_value in-place, keeping only the keys listed in keys_to_retain. The keys are matched recursively by combining the current key with the current_root, allowing for nested field retention.

Keys marked as Full, are retained as-is. For keys marked as Partial, the function recurses into nested objects to retain matching subfields.

Function respects the camelCase serde_json attribute for structures. This means that "camelCaseKey" key will be retained in JSON blob if "camel_case_key" exists in keys_to_retain.

Intended to be used from build_struct_json_patch macro.