Skip to main content

get_config_section

Function get_config_section 

Source
pub fn get_config_section(
    config_json: &str,
    section_name: &str,
    filter: Option<&str>,
) -> Result<Vec<Value>>
Expand description

Get items from a configuration section with optional filtering

§Arguments

  • config_json - Configuration JSON string
  • section_name - Name of the section to get
  • filter - Optional filter string to search in records

§Returns

Returns a vector of items from the section

§Example

use sz_configtool_lib::config_sections;

let config = r#"{"G2_CONFIG": {"CFG_ATTR": [{"ATTR_CODE": "NAME"}]}}"#;
let items = config_sections::get_config_section(config, "CFG_ATTR", None).unwrap();
assert_eq!(items.len(), 1);