Link to home
Start Free TrialLog in
Avatar of sqlcurious
sqlcuriousFlag for United States of America

asked on

need help with extracting google+ term from the string

Hi Experts, need help in extracting google+ from the following string whenever I have this "providerName";s:7:"Google+";s:10:"

DECLARE @response VARCHAR(MAX)

SET @response='a:4:{s:4:"stat";s:2:"ok";s:7:"profile";O:8:"stdClass":12:{s:12:"providerName";s:7:"Google+";s:10:"identifier";s:53:"https://www.google.com/profiles/110433849914130156555";s:13:"verifiedEmail";s:18:"dbsalyer@gmail.com";s:17:"preferredUsername";s:8:"dbsalyer";s:11:"displayName";s:10:"Dan Salyer";s:4:"name";O:8:"stdClass":3:{s:9:"formatted";s:10:"Dan Salyer";s:9:"givenName";s:3:"Dan";s:10:"familyName";s:6:"Salyer";}s:5:"email";s:18:"dbsalyer@gmail.com";s:3:"url";s:45:"https://plus.google.com/110433849914130156555";s:5:"photo";s:99:"https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=400";s:6:"gender";s:4:"male";s:12:"googleUserId";s:21:"110433849914130156555";s:17:"providerSpecifier";s:10:"googleplus";}s:11:"merged_poco";O:8:"stdClass":10:{s:2:"id";s:21:"110433849914130156555";s:11:"displayName";s:10:"Dan Salyer";s:17:"preferredUsername";s:8:"dbsalyer";s:6:"gender";s:4:"male";s:10:"profileUrl";s:45:"https://plus.google.com/110433849914130156555";s:4:"name";O:8:"stdClass":3:{s:9:"formatted";s:10:"Dan Salyer";s:9:"givenName";s:3:"Dan";s:10:"familyName";s:6:"Salyer";}s:6:"emails";a:1:{i:0;O:8:"stdClass":2:{s:5:"value";s:18:"dbsalyer@gmail.com";s:4:"type";s:7:"account";}}s:15:"languagesSpoken";a:1:{i:0;s:2:"en";}s:4:"urls";a:1:{i:0;O:8:"stdClass":2:{s:5:"value";s:45:"https://plus.google.com/110433849914130156555";s:4:"type";s:7:"profile";}}s:6:"photos";a:1:{i:0;O:8:"stdClass":2:{s:5:"value";s:99:"https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=400";s:4:"type";s:5:"other";}}}s:17:"accessCredentials";O:8:"stdClass":7:{s:11:"accessToken";s:83:"ya29.cwEkau4rm8aC0Tu1kIVN5kvmcS8nHwqo1kJlntsFOS6oKZMZMe8Rd_0g-wWQP9amXs1AeG88JfIcLw";s:3:"uid";s:21:"110433849914130156555";s:7:"expires";i:1431644921;s:12:"refreshToken";s:45:"1/SPFF7AlKHi4NVs8km62TZTTGebREYSEPmW4eC3W_Ipk";s:6:"scopes";s:13:"email,profile";s:8:"clientId";s:72:"669725107013-vvps89hat4g4u7ri9hiqb818pks36qcf.apps.googleusercontent.com";s:4:"type";s:6:"oauth2";}}'
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Not following your question . . . what are your expected results given that response?
ASKER CERTIFIED SOLUTION
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sqlcurious

ASKER

@kyle Abrahams, thanks for the response, every time I pass a string like in the example, result should be 'google+ ' but in that string I need to have "providerName";s:7:"Google+";s:10:"

@zephyr_hex I will try that approach, will update on more questions which I am sure I will have, thanks for the response
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot Kyle Abrahams what you have mentioned serves the purpose but looks like I misunderstood the requirement, I just came to know that I need to extract anything that it's in the place of google+ For ex:
Below are the scenarios and results:
Result should be 'google+ ' if in the string I have "providerName";s:7:"Google+";s:10:"
Result should be 'yahoo+ ' if in the string I have "providerName";s:7:"yahoo+";s:10:"
Result should be 'bing+ ' if in the string I have "providerName";s:7:"bing+";s:10:"

pls suggest, thanks
I suggest you parse the json string as I mentioned above.
Thanks for the advice, it worked