Skip to main content

project_json

Function project_json 

Source
pub fn project_json(value: &Value, selected_fields: &HashSet<String>) -> Value
Expand description

Project a JSON value to only include selected fields.

Supports dot notation for nested field selection (e.g., access_control.read). For objects, recursively includes only the specified fields. For arrays, projects each element. For other types, returns the value unchanged.

§Arguments

  • value - The JSON value to project
  • selected_fields - Set of field names to include (case-insensitive, supports dot notation)

§Returns

A new JSON value containing only the selected fields

§Examples

// Select top-level field
$select=id,name

// Select nested field (includes entire nested object)
$select=access_control

// Select specific nested field
$select=access_control.read,access_control.write