MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / parse_inline_list

Function parse_inline_list

crates/opencode-config/src/loader.rs:854–868  ·  view source on GitHub ↗

Parse an inline YAML flow sequence like `[a, b, c]` into a JSON array.

(value: &str)

Source from the content-addressed store, hash-verified

852
853/// Parse an inline YAML flow sequence like `[a, b, c]` into a JSON array.
854fn parse_inline_list(value: &str) -> Option<serde_json::Value> {
855 let trimmed = value.trim();
856 if !trimmed.starts_with('[') || !trimmed.ends_with(']') {
857 return None;
858 }
859 let inner = trimmed[1..trimmed.len() - 1].trim();
860 if inner.is_empty() {
861 return Some(serde_json::Value::Array(Vec::new()));
862 }
863 let items: Vec<serde_json::Value> = inner
864 .split(',')
865 .map(|item| yaml_scalar_to_json(item.trim()))
866 .collect();
867 Some(serde_json::Value::Array(items))
868}
869
870/// Parse an inline YAML flow mapping like `{a: 1, b: true}` into a JSON object.
871fn parse_inline_map(value: &str) -> Option<serde_json::Value> {

Callers 2

parse_yaml_mapping_linesFunction · 0.85
parse_yaml_list_linesFunction · 0.85

Calls 3

newFunction · 0.85
yaml_scalar_to_jsonFunction · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected