I know that there are already multiple questions about parsing JSON files in Typescript, but non of these helped me.
I'm trying to parse the result of the license-checker output which is a json:
{
"@angular/core@10.1.4": {
"licenses": "MIT",
"repository": "https://github.com/angular/angular",
"publisher": "angular",
"name": "@angular/core",
"version": "10.1.4",
"description": "Angular - the core framework",
"licenseFile": "C:\\Users\\UC190\\workspace\\core-search-app\\node_modules\\@angular\\core\\README.md",
"licenseText": "Angular\n=======\n\nThe sources for this package are in the main [Angular](https://github.com/angular/angular) repo. Please file issues and pull requests against that repo.\n\nUsage information and reference details can be found in [Angular documentation](https://angular.io/docs).\n\nLicense: MIT",
"path": "C:\\Users\\UC190\\workspace\\core-search-app\\node_modules\\@angular\\core"
},
"@angular/forms@10.1.4": {
"licenses": "MIT",
"repository": "https://github.com/angular/angular",
"publisher": "angular",
"name": "@angular/forms",
"version": "10.1.4",
"description": "Angular - directives and services for creating forms",
"licenseFile": "C:\\Users\\UC190\\workspace\\core-search-app\\node_modules\\@angular\\forms\\README.md",
"licenseText": "Angular\n=======\n\nThe sources for this package are in the main [Angular](https://github.com/angular/angular) repo. Please file issues and pull requests against that repo.\n\nUsage information and reference details can be found in [Angular documentation](https://angular.io/docs).\n\nLicense: MIT",
"path": "C:\\Users\\UC190\\workspace\\core-search-app\\node_modules\\@angular\\forms"
},
...
}
Therefore I created an interface to parse the elements:
export interface JsonData {
licenses: string;
repository: string;
publisher: string;
name: string;
version: string;
description: string;
licenseFile: string;
licenseText: string;
path: string;
}
But I am struggling on how to iterate over the elements and parse them to a list of JsonData
.