SELECT `justfunctions.eu.parse_yaml`("--- updated_at: - 2023-11-12 08:08:25.291779000 Z - 2023-11-12 08:25:18.648572080 Z status: - new - canceled ")
/*--Output--
{'status': ['new', 'canceled'], 'updated_at': ['2023-11-12T08:08:25.291Z', '2023-11-12T08:25:18.648Z']}
*/
CREATE OR REPLACE FUNCTION `your_project_id.your_dataset_id.parse_yaml`(`string` string) RETURNS json
LANGUAGE js AS r'''try {
return jsyaml.load(string);
} catch(e) {
return '{}';
}
''' OPTIONS ( description = '''Converts a YAML <string> to JSON format.''' , library = [ "gs://justfunctions/bigquery-functions/js-yaml.min.js" ] )
JavaScript User Defined Function (JavaScript UDF)
See something wrong? Contact us or report an issue on Github.