Skip to main content

flex_string_opt

Function flex_string_opt 

Source
pub fn flex_string_opt<'de, D>(d: D) -> Result<Option<String>, D::Error>
where D: Deserializer<'de>,
Expand description

Deserialise Option<String> from a JSON string, array-of-strings, or null.

Many free-text fields in the MHLW schema are typed as plain String, but LLMs sometimes return them as arrays (e.g. ["CO2", "NH3"] for Substance, or ["text line 1", "text line 2"] for FullText). This helper accepts both forms: a bare string is used as-is, while an array is joined with ā€œ\nā€.