Skip to main content

Notifications

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

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

Posted on by 122
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,345 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans