I am trying to map a large/complex/valid JSON string - I only need a set of nested keys as a string array, the rest can be ignored.
I am doing this in Typescript and would like to parse to a JSON Object such as
export interface OpenApi {
paths: string[];
}
Here is the [relevant part] json:
{
"openapi": "3.0.1",
"info": {
"title": "title",
"version": "2018-05-10"
},
"paths": {
"/api/path1": {"ignore" ...},
"/api/path2": {"ignore" ...},
"/api/path3": {"ignore" ...}
}
...
}
to map to the above object array of strings
OpenApi.paths = ["/api/path1", "/api/path2", "/api/path3"]
the rest of the json aside from the keys can be ignored.
Any help appreciated! Thank you
JSON.parseto it? Do you simply want to cast the result to your OpenApi interface, or do you actively want to validate the JSON to ensure it conforms to your expected interface?