Squeak
May 26, 2020Cirrus
Parse username from server response
Hi,
I´m trying to parse a username from a response that I´m receiving from a external server.
The complete response from the server·
HTTP/1.1 200 OK Cache-Control: private Content-Type: application/json; charset=utf-8 Server: Microsoft-IIS/10.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Mon, 25 May 2020 10:18:21 GMT Content-Length: 47 {"pid":"asdf001","mobileNumber":"+12345678909"}
I´m using "findstr" to search for the username.
set parse_user [findstr $recv_data "pid" 5 ","]
log local0. " status ---->>>$parse_user"
The log local0. looks this
"asdf001"
My question is, how do I remove the quotes on both sides of the username?
Thanks in advance.
Hi Squeak,
You can use string map to strip the double quotes.
set strip_quotes [string map {\" {}} $parse_user]
Kind regards
Ben