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
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.
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); }
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
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); }
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156