Create a JSON Object from a JSON array in JavaScript - No jQuery
Budget: $10 – $30 USD
I need to pass a multi element object via AXIOS to a .Net Web API. The array needs to be converted into an object and JSON.stringify does not work. The object could be as many as 100 objects each with their own objects. When I pass one everything works fine but I need help to build the string to pass the entire payload.
The final output will look something like if there are 3 elements
let payload = {"FacultyMember":"A, P","FundingSource":"NIH","GrantNumber":"5R01CA253460-02","Role":"PI","GrantTitle":"Collagen Sequence Variants in Racial Disparities of Breast Cancer","ProjectPeriod":"06/2020-05/2025","DirectCost":367214},
{"FacultyMember":"A, P","FundingSource":"NIH","GrantNumber":"1R21CA263464-01","Role":"PI","GrantTitle":"Cellular Sources of Pathological Stromal Variants","ProjectPeriod":"06/2021-05/2023","DirectCost":116875},
{"FacultyMember":"A, P","FundingSource":"NIH","GrantNumber":"1S10OD030212-01","Role":"PI","GrantTitle":"Bruker scimaX™ Magnetic Resonance Mass Spectrometer","ProjectPeriod":"08/2021-08/2022","DirectCost":1746141}
And this is taking the value from the array and populating the objects of
{"FacultyMember":"FundingSource":"GrantNumber":"Role":"GrantTitle":"ProjectPeriod":"DirectCost"}
The code will go into a Quasar/Vue.js application using an Axios database call to a .Net Web API
All I need is a stand alone function that will convert the array into a JSON Object
The final output will look something like if there are 3 elements
let payload = {"FacultyMember":"A, P","FundingSource":"NIH","GrantNumber":"5R01CA253460-02","Role":"PI","GrantTitle":"Collagen Sequence Variants in Racial Disparities of Breast Cancer","ProjectPeriod":"06/2020-05/2025","DirectCost":367214},
{"FacultyMember":"A, P","FundingSource":"NIH","GrantNumber":"1R21CA263464-01","Role":"PI","GrantTitle":"Cellular Sources of Pathological Stromal Variants","ProjectPeriod":"06/2021-05/2023","DirectCost":116875},
{"FacultyMember":"A, P","FundingSource":"NIH","GrantNumber":"1S10OD030212-01","Role":"PI","GrantTitle":"Bruker scimaX™ Magnetic Resonance Mass Spectrometer","ProjectPeriod":"08/2021-08/2022","DirectCost":1746141}
And this is taking the value from the array and populating the objects of
{"FacultyMember":"FundingSource":"GrantNumber":"Role":"GrantTitle":"ProjectPeriod":"DirectCost"}
The code will go into a Quasar/Vue.js application using an Axios database call to a .Net Web API
All I need is a stand alone function that will convert the array into a JSON Object