Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deserializing PHP Data from Web service

I'm receiving data from a web service. The data are in the following format:

a:5:{s:7:"request";s:14:"94.190.179.118";s:6:"status";i:206;s:12:"currencyCode";s:3:"BGL";}

I need to parse the input.

Can you advise me what format is this and what is the easiest way to parse them?

...

I can parse by splitting the string by ';' and to search the individual elements for the wanted key and the following value. (possible, but bad solution) Probably the data are serialized in a standard format and can be deserialized in a dictionary.

like image 304
Miroslav Popov Avatar asked Apr 04 '14 11:04

Miroslav Popov


1 Answers

This looks like serialized PHP: http://php.net/serialize

PHP includes built in deserialize methods. As for C#, there might be 3rd library somewhere that will do this for you.

My advice would be to see if you can have the API communicate in a standardised format such as JSON or XML. Failing that, you will need to convert it from a serialized string, to usable object data in C#.

like image 108
George Avatar answered Sep 25 '22 20:09

George