1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Best way to parse json and extract attribute values dynamically in Angular [duplicate]

Discussão em 'Angular' iniciado por Surodip, Abril 28, 2025.

  1. Surodip

    Surodip Guest

    I am working new in Angular and working in a work where REST API returns a complex json entity and dynamically I have to fill html page components with values from the output json. The json structure will be like having mulltiple arrays in it. I need help with identifying json attributes at runtime by comparing json array fields, extract particular array item and attribute values from that and put into html component. My JSON structure will be like below:

    {
    "code": "0",
    "status": "SUCCESS",
    "hasError": false,
    "responsePayload": {
    ......
    "listOfParties": [
    {
    "role": "Primary Contact",
    "fullName": "John Doe",
    "gender": "Male",
    "dateOfBirth": "01/01/1985",
    "partyCode": "PTYCODE01"
    },
    {
    "role": "Service Manager",
    "fullName": "Smith Murphy",
    "gender": "Male",
    "partyCode": "PTYCODE02"
    }
    ],
    .......
    }


    From above json, I need to scan "listOfParties" and match "role" and after it matches with "Primary Contact", need to get the "partyCode" and set it in input text in html page.

    I have tried with: jsonObject["listOfParties[0].partyCode", but couldn't get how to match it with "role" and then get "partyCode". Can I do it with setting jsonPath or some better way to do it.

    Thanks.

    Continue reading...

Compartilhe esta Página