Received data from external system in Object format. Due to this not able to read the content in a tool. To read the content need to convert into Array format. How to convert object into Array ?

Sample content:

{
headers:  {
date: Mon, 25 Jan 2021 13:41:24 GMT,
server: Microsoft-IIS/10.0,
cache_control: private, max-age:600,
content_type: application/json; odata.metadata=minimal; odata.streaming=true; charset=utf-8,
content_encoding: gzip,
vary: Accept-Encoding,
strict_transport_security: max-age=31536000; preload,
odata_version: 4.0,
x_powered_by: ASP.NET,
transfer_encoding: chunked
},
response:  {
_odata.context: https://extranet.who.int/xmart-api/odata/NCOV_CAA/$metadata#FACT_VAC_OUTPUT,
value:  [
 {
DATE: 2020-12-15,
BATCH_ID: 30057,
ROUND_FK: 2,
ALG_VERSION_ID: 1,
PARTICIPANT_FK: BEL,
VAC_PRODUCT_FK: VA_S1,
ALLOCATION_ROUND: 50000,
PARTICIPANT_RANK: 1,
ALLOCATION_TOTAL: 50000,
},
 {
DATE: 2020-12-15,
BATCH_ID: 90015,
ROUND_FK: 9,
ALG_VERSION_ID: 1,
PARTICIPANT_FK: KEN,
VAC_PRODUCT_FK: VA_S1,
ALLOCATION_ROUND: 234000,
PARTICIPANT_RANK: 1,
ALLOCATION_TOTAL: 234000,
}
]
},
Status code: 200,
Error: ,
Body: {"@odata.context":"https://extranet.who.int/xmart-api/odata/NCOV_CAA/$metadata#FACT_VAC_OUTPUT","value":[{"DATE":"2020-12-15","BATCH_ID":30057,"ROUND_FK":"2","ROUND_FK__Sys_ID":"36bb74ed-d034-4120-a324-5f9e16ffd6d9","ROUND_FK__CODE":2,"ALG_VERSION_ID":"1","PARTICIPANT_FK":"BEL","PARTICIPANT_FK__Sys_ID":"6a16fdc9-b523-48e3-be6b-d0493f9c1ff4","PARTICIPANT_FK__PARTICIPANT_ID":"BEL","VAC_PRODUCT_FK":"VA_S1","VAC_PRODUCT_FK__Sys_ID":"c6a93e69-c478-43cf-a3b1-bf691bb815f5","VAC_PRODUCT_FK__VAC_PRODUCT_ID":"VA_S1","ALLOCATION_ROUND":50000,"PARTICIPANT_RANK":1,"ALLOCATION_TOTAL":50000,"_RecordID":"04bf1656-d868-48a8-a12f-0050d137aaab","Sys_RowTitle":"30057BELVA_S1","Sys_Version":1,"Sys_VersionID":"04BF1656-D868-48A8-A12F-0050D137AAAB.1","Sys_OriginID":"d36dbe35-aade-4c0e-9f2b-fb9d52e44878","Sys_OriginCode":"SYS_MART_IMPORT","Sys_LoadBy":"xAdmin","Sys_CommitDateUtc":"2021-01-25T09:23:38.463Z","Sys_FirstLoadBy":"xAdmin","Sys_FirstCommitDateUtc":"2021-01-25T09:23:38.463Z","Sys_ID":"0…
}

Expected output with below fields in Array

DATE 
BATCH_ID 
ROUND_FK 
ALG_VERSION_ID 
PARTICIPANT_FK 
VAC_PRODUCT_FK 
ALLOCATION_ROUND 
PARTICIPANT_RANK 
ALLOCATION_TOTAL 
edited by MattIPv4

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer
by William Imoh
One of the most popular methods of iterating through datasets in JavaScript is the `.map()` method. `.map()` creates an array from calling a specific function on each item in the parent array. `.map()` is a non-mutating method that creates a new array instead of changing the original. In this tutorial, we'll look at four noteworthy uses of `.map()` in JavaScript: calling a function of array elements, converting strings to arrays, rendering lists in libraries, and reformatting array objects.