After making a get request, I received JSON data in the following format:
{
"name" : "cow",
"date" : {
"year" : 2012,
"month" : "JANUARY",
"dayOfMonth" : 1,
"dayOfWeek" : "FRIDAY",
"dayOfYear" : 1,
"monthValue" : 1,
"hour" : 2,
"minute" : 2,
"second" : 0,
"nano" : 0,
"chronology" : {
"id" : "ISO",
"calendarType" : "iso8601"
}
}
....
}
I want to convert the above JSON object into the following format using TypeScript/Angular:
{
"name" : "cow",
"date" : "2012-01-01"
}
Once converted, I need to store it in an array defined below.
//....correctFormat = [];
service.convertStore()
.subscribe((data: any) => {
// perform necessary manipulations here
correctFormat = "holds the final result"
})