I'm currently learning JavaScript and need to convert a YAML file to an Interface in JavaScript. Here is an example of the YAML file:
- provider_name: SEA-AD
consortiumn_name: SEA-AD
defaults: thumbnail
Donors:
- id: "https://portal.brain-map.org/explore/seattle-alzheimers-disease#Human-MTG-10x_SEA-AD_Male_TissueBlock"
label: Registered 2/20/2023, Rebecca Hodge, SEA-AD
description: "4 x 4 x 5 millimeter, 0.11 millimeter"
link: "https://portal.brain-map.org/explore/seattle-alzheimers-disease"
sex: Male
Blocks:
- id: https://portal.brain-map.org/explore/seattle-alzheimers-disease#Human-MTG-10x_SEA-AD_Male_TissueBlock
label: Registered 2/20/2023, Rebecca Hodge, SEA-AD
And here is the TypeScript interface:
export interface Provider {
provider_name: string;
provider_uuid: string;
consortium_name: string;
defaults: string;
donors: Donor[]
}
export interface Donor {
id: string;
label: string;
description: string;
link: string;
age: number;
sex: string;
bmi: number;
blocks: Block[];
}
export interface Block {
id: string;
label: string;
}
Currently, I am struggling with mapping the inner variables like the "Donors" in the YAML file using JavaScript. Here is what I have tried so far:
cosnt data = load("YAML File");
const provider = {
provider_name: data.provider_name,
consortium_name : data.consortium_name,
dafaults: data.defaults,
donors: data.Donors.map(function (donor) {
As someone new to JavaScript, I would appreciate any guidance on whether I am approaching this correctly or if there is a different method I should be using. The map function seems to be causing issues, as it is not available in JavaScript. Any suggestions or references would be highly valued. Thank you!