简体   繁体   中英

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM