5

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.

4
  • Is that even a standart data format? Commented Apr 4, 2014 at 11:45
  • It's not XML and Json. I hope someone will recognize it. Probably 'a' means count of records. s - length of the following string, i - integer.. Commented Apr 4, 2014 at 11:46
  • Any documentation on this "format"? Why not ask the supplier to provide data in a more standard format? Commented Apr 4, 2014 at 11:47
  • Yes. I'm facing the same issue. Its PHP serialized data coming from a web service. Commented May 4, 2017 at 10:12

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

Comments

4

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

1 Comment

Hi Anton, Its not working. Its de serializing data, but output result is not getting any of the value and also most of the key values are missing...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.