Question

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.

Was it helpful?

Solution 2

This is PHP's own serialization format. Try Sharp Serialization Library to read this in.

OTHER TIPS

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#.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top