Struggling with the syntax to properly map my incoming data in a static method. The structure of my json Array is as follows:
[
{
"documents": [
{
"title": "+1 (film)",
"is-saved": false,
"abstract": "some text",
"id": "_1__film_",
"url": "some url"
}
]
}
]
Each element in the array represents a Result
.
While I understand how to map one Result, here's an example:
static resultFromJSON(json): Result {
let documents: SearchQueryDocument[] =
json.documents.map(doc => new SearchQueryDocument(doc.title, doc.issaved, doc.abstract, doc.id, doc.url))
return new Result(documents)
}
However, I'm struggling with mapping the entire array. How can I achieve this?
static resultsFromJSON(json): Result[] {
let results: Result =
json.map ... // what should go here?
}
Mapping one result using json.documents.map...
is straightforward, but when it comes to mapping the whole array, I'm stuck.
I may be a newbie asking a seemingly simple question, but any guidance would be greatly appreciated!