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

Announcements

No record found.

News and Announcements icon
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
    239,087 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans