pub fn add_config_section_field(
config_json: &str,
section_name: &str,
field_name: &str,
field_value: &Value,
) -> Result<(String, usize)>Expand description
Add a field to all items in a configuration section
§Arguments
config_json- Configuration JSON stringsection_name- Section namefield_name- Field name to addfield_value- Value for the field
§Returns
Returns (modified_config, item_count) tuple on success
§Example
use sz_configtool_lib::config_sections;
use serde_json::json;
let config = r#"{"G2_CONFIG": {"CFG_ATTR": [{"ATTR_CODE": "NAME"}]}}"#;
let (modified, count) = config_sections::add_config_section_field(
config,
"CFG_ATTR",
"NEW_FIELD",
&json!("default")
).unwrap();
assert_eq!(count, 1);