Solved

Deserialisation in C#

Posted on 2014-03-24
4
182 Views
Last Modified: 2014-03-24
Hi all,

I was wondering if anyone can please advise. Basically I'm using memcache. The idea is that a php systems serialises an object and puts it on the memcache. I then retrieve it in my C# project and de-serialises it.

I cant see any of the php side of it and should be just able to de-serialise it. The data I have is like this.

SESSION_STUFF|a:1:{i:-1;s:0:"";}

Apparently above is already serialised. So I need to get it into a memory stream and de-serialise as above.

Any advice would be really appreciated. This is one of the toughest tests I have faced.

Thanks in advance.
0
Comment
Question by:meetsys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 39949817
The problem is that you can serialise an object in many different ways, its not like there is one way to do it. Therefore you have to know how PHP serialises an object to be able to deserialise it.

However with a bit of a google search it appears someone has already solved the problem for you: http://sourceforge.net/projects/csphpserial/
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 39949822
that data looks like JSON encoded data:
http://en.wikipedia.org/wiki/JSON
so, you use the DataContractJsonSerializer  class:
http://msdn.microsoft.com/en-us/library/bb412179%28v=vs.110%29.aspx
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 39949968
Rather than serializing an object with PHP serialize() you want to json_encode() the object.  The results is still a data string that represents an object, but the advantage of the JSON string is that it is a widely supported format that plays well outside of PHP, making sense to other programming lanugages, JavaScript, etc.

See also this cautionary tale.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39950150
Hi, meetsys.  I see you are new to Experts-Exchange.  The community standards incorporate the grading guidelines.  If you were unhappy with the answers, you're expected to engage in dialog with the Expert community to satisfy your issues.  If you were happy with the answers, the correct (and default) grade is "A."

http://support.experts-exchange.com/customer/portal/articles/481419

Please let us know if you didn't understand the answer or if we let you down in some way.  Thanks. ~Ray
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Horizontal Full Calendar using php 5 44
Cannot locate cell 15 43
PHP and accessing Array Elements 3 34
C# Web service insert into Oracle table 8 43
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question