d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Javascript - Parse A Nested Array For Fg
Add Reply New Topic New Poll
Retired Moderator
Posts: 35,627
Joined: Jan 12 2007
Gold: 57,693.62
Trader: Trusted
Aug 9 2022 01:39pm
I'm an awful programmer and trying to parse a JSON payload response for an integration. Willing to pay Fg for anyone who can write the snippet of code that will parse this sample payload:


Code
{
attributes: [
{
handle: 'email',
name: 'Email',
value: 'john.doe@gmail.com
},
{ handle: 'fname', name: 'First Name', value: 'John' },
{ handle: 'group', name: 'Group Association', value: null },
{ handle: 'lname', name: 'Last Name', value: 'Doe' },
{ handle: 'zip', name: 'Postal Code', value: '45383' },
{
handle: 'id',
name: 'Unique Identifier',
value: '534534535'
}
],
status: [ { group: 'student', subgroups: [Array], verified: true } ]
}


The array is being stored as variable bodyParse
Code
let bodyParsed;
try {
bodyParsed = JSON.parse(body);
} catch (jsonError) {
return callback(new Error(body));
}


The code must identify if the "name" exists in the payload, and if it does, fetch the value of that array and store it as a variable.


Expected Outcome:
email = john.doe@gmail.com
fname = john
lname = Doe
zip = 45383

group = student
verified = true

This post was edited by Ryans on Aug 9 2022 02:01pm
Retired Moderator
Posts: 35,627
Joined: Jan 12 2007
Gold: 57,693.62
Trader: Trusted
Aug 10 2022 09:17am
Ended up finishing this. Please disregard.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll