Skip to main content

set_fragment

Function set_fragment 

Source
pub fn set_fragment(
    config_json: &str,
    fragment_code: &str,
    fragment_config: &Value,
) -> Result<String>
Expand description

Update an existing fragment in the configuration

§Arguments

  • config_json - Configuration JSON string
  • fragment_code - Fragment code to update
  • fragment_config - New configuration for the fragment

§Returns

Returns modified configuration JSON on success

§Example

use sz_configtool_lib::fragments;
use serde_json::json;

let config = r#"{"G2_CONFIG": {"CFG_ERFRAG": [{"ERFRAG_ID": 1, "ERFRAG_CODE": "TEST"}]}}"#;
let new_config = json!({"ERFRAG_SOURCE": "NAME+DOB"});
let modified = fragments::set_fragment(config, "TEST", &new_config).unwrap();