Skip to main content

fallow_config/
jsonc.rs

1use serde::de::DeserializeOwned;
2
3pub fn parse_options() -> jsonc_parser::ParseOptions {
4    jsonc_parser::ParseOptions {
5        allow_comments: true,
6        allow_loose_object_property_names: false,
7        allow_trailing_commas: true,
8        allow_missing_commas: false,
9        allow_single_quoted_strings: false,
10        allow_hexadecimal_numbers: false,
11        allow_unary_plus_numbers: false,
12    }
13}
14
15pub fn parse_to_value<T: DeserializeOwned>(
16    content: &str,
17) -> Result<T, jsonc_parser::errors::ParseError> {
18    jsonc_parser::parse_to_serde_value(content, &parse_options())
19}