Parse input string as JSON or YAML and return a serde_json::Value. # Arguments `input` - The input string to parse (JSON or YAML format) `context` - Context string for error messages (e.g., "file parameters", "inline parameters") # Returns `Result ` - Parsed JSON value # Errors This function will return an error if the input cannot be parsed as valid JSON or YAML
(input: &str, context: &str)
| 598 | /// |
| 599 | /// This function will return an error if the input cannot be parsed as valid JSON or YAML |
| 600 | fn parse_input_to_json_value(input: &str, context: &str) -> Result<serde_json::Value, DscError> { |
| 601 | match serde_json::from_str(input) { |
| 602 | Ok(json) => Ok(json), |
| 603 | Err(_) => { |
| 604 | match serde_yaml::from_str::<serde_yaml::Value>(input) { |
| 605 | Ok(yaml) => Ok(serde_json::to_value(yaml)?), |
| 606 | Err(err) => { |
| 607 | Err(DscError::Parser(t!(&format!("util.failedToParse{context}"), error = err.to_string()).to_string())) |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | /// Convert parameter input to a map, handling different formats. |
| 615 | /// |
no test coverage detected