web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to get particular words from group of sting value

(0) ShareShare
ReportReport
Posted on by 570

Dear All,

I am getting one sting output  like this,

"8D8hZUgfk_NaqgawkRO5rC00xfHPwSSC3pMDxNX1GDhKedghSbVh8tTKivtcbz-VXmVFbKqW1m8YDAKJ5BCkXqb3F8RsGc2UdoPCGrk5H4","token_type":"TXT","expires_in":TOS"

 from the output ,I need only "token_type":"TXT",How i can get this particular word from the output 

BR,

Tony 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi Tony!

    You should use str functions.


    static void Job174(Args _args) { str text = "8D8hZUgfk_NaqgawkRO5rC00xfHPwSSC3pMDxNX1GDhKedghSbVh8tTKivtcbz-VXmVFbKqW1m8YDAKJ5BCkXqb3F8RsGc2UdoPCGrk5H4,token_type:TXT,expires_in:TOS"; str text2; int firstComma, secondComma; firstComma = strFind(text, "," , 1, strLen(text)) + 1; secondComma = strFind(text, ",", firstComma, strLen(text)); text2 = subStr(text, firstComma, secondComma - firstComma); info(text2); }
  • TonyAx Profile Picture
    570 on at

    Hi Rustem Galiamov,

    Thanks for replay its very use for me,But sorry now only i noted that real output below like this from that only ,I need token_type:TXT  ,

    {"access_token":"9OV9Xk-PSQqYY6OKGoJRyj5O7dIg-71PCa3-kS_h3Ayp1vNEe-D-ZMneYr9RvX7XNx9OdnvkG6141GLYHMr23RzZ2FyeqJu9xfDaYR193JfqQ_cI0JXbgo1zbeXigD3gDKX-QfgbttYhf8DkCDk_FtF2KSG-abgI69gjZOYZ2UToSAQ0fmuxccf2x70pUQKN_dnLbor2QiyW93eGLVMSVJD1rk6X37GBj_diGjZHIKc","token_type":"TXT","expires_in":86399}

    please give any solution on this.

    BR

    Tony

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Ok, try this:

    static void Job174(Args _args)
    {
        str text = '{"access_token":"9OV9Xk-PSQqYY6OKGoJRyj5O7dIg-71PCa3-kS_h3Ayp1vNEe-D-ZMneYr9RvX7XNx9OdnvkG6141GLYHMr23RzZ2FyeqJu9xfDaYR193JfqQ_cI0JXbgo1zbeXigD3gDKX-QfgbttYhf8DkCDk_FtF2KSG-abgI69gjZOYZ2UToSAQ0fmuxccf2x70pUQKN_dnLbor2QiyW93eGLVMSVJD1rk6X37GBj_diGjZHIKc","token_type":"TXT","expires_in":86399}';
        str text2;
        int firstComma, secondComma;
        
        firstComma  = strFind(text, "," , 1, strLen(text)) + 1;
        secondComma = strFind(text, ",", firstComma, strLen(text));
        
        text2 = subStr(text, firstComma, secondComma - firstComma); 
        text2 = strRem(text2, '"');
        
    
        info(text2);
    }


  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    It can be done in many ways. The string seems to be JSON, therefore deserializing it to an object or a map sounds like the most natural approach. Then you'll simply check the value of "token_type".

    You could also split the string by comma with strSplit() and then either take the second element (if the order is fixed and the token can't contain comma) or then one starting with "token_type". Yet another solution would be using regular expressions. I would prefer handling it as JSON, though.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans