Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

How to iterate and get value from nested json array using RetailCommonWebAPI

(0) ShareShare
ReportReport
Posted on by 22
Hi All,
 
how to iterate this json and get the value of key1 and key2
 
{
  /statusCode/: /00/,
  /message/: /success/,
  /result/: {
    /key1/: /a/,
    /key2/: /b/
  }
}
 
Thanks
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,255 Super User 2024 Season 2 on at
    How to iterate and get value from nested json array using RetailCommonWebAPI
    Hi it.dev,

    can you please show us the code. The contract for this json, and the line of code that returns this json?

    but in general, since you didn't share any code, then i will assume the json returned to you is a list (contractList), if that's the case, here's how u can get the value of key1 and key2
    ListEnumerator           retailWebAPIEnum;
    RetalWebAPIContract      contract;
    List resultsContractList;
    ListEnumerator resultContractEnum ;
    ResultsContract resultContract; if(contractList) // assume this is the list of json already returned to you { retailWebAPIEnum= contractList.getEnumerator(); if(retailWebAPIEnum) { while (retailWebAPIEnum.moveNext()) { contract = retailWebAPIEnum.current(); resultsContractList= contract.Results();
     
    if(resultsContractList.elements())
            {
                resultContractEnum = resultsContractList.getEnumerator();

            if(resultContractEnum)
            {
                while (resultContractEnum.moveNext())
                {
                    resultContract= resultContractEnum.current();
    resultContract.Key1(); resultContract.Key2();
      }
      }
      } } } }

    Thanks,
    Layan Jweihan

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans