zattz
asked on
read a serialized php array in c#
How do you read a serialized php array in c#?
Please try JSON serializer for this...or JS below in C#
JavaScriptSerializer serializer = new JavaScriptSerializer();
var output = seriaizer.Serialize(your_a non_object );
Please refer the attached code for Json
Hope this will help...
Thanks, Kalpan
JavaScriptSerializer serializer = new JavaScriptSerializer();
var output = seriaizer.Serialize(your_a
Please refer the attached code for Json
Hope this will help...
Thanks, Kalpan
var serializer = new DataContractJsonSerializer(thing.GetType());
var ms = new MemoryStream();
serializer.WriteObject(ms, thing);
var json = Encoding.Default.GetString(ms.ToArray());
Use the XMLSeralizer class if you are using the soap services with php..or to get the XML file...
Please refer the below one...
http://msdn.microsoft.com/en-us/library/90c86ass(VS.71).aspx
Please refer the below one...
http://msdn.microsoft.com/en-us/library/90c86ass(VS.71).aspx
ASKER
I can't get that json deserializer to work.
This is an example of the string array serialized by php:
a:5:
{s:19:"interlinking_method ";s:6:"ran dom";s:19: "interlink ing_source ";s:5:"gro up";s:29:" interlinki ng_update_ frequency" ;s:1:"9";s :22:"inter linking_mi n_links";s :1:"2";s:2 2:"interli nking_max_ links";s:1 :"7";
This is an example of the string array serialized by php:
a:5:
{s:19:"interlinking_method
please use the following link...and refer the attached code...
You can do this by XML serializer to prepare the XML file with PHP and than deseralize in C#
http://www.devshed.com/c/a/PHP/Serializing-XML-With-PHP/1/
http://devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236
Hope that would work for you...
thanks, Kalpan
You can do this by XML serializer to prepare the XML file with PHP and than deseralize in C#
http://www.devshed.com/c/a/PHP/Serializing-XML-With-PHP/1/
http://devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236
Hope that would work for you...
thanks, Kalpan
// include class file
include("Serializer.php");
// create object
$serializer = new XML_Serializer();
// create array to be serialized
$xml = array ( "book" => array (
"title" => "Oliver Twist",
"author" => "Charles Dickens"));
// perform serialization
$result = $serializer->serialize($xml);
// check result code and display XML if success
if($result === true)
{
echo $serializer->getSerializedData();
}
//////////////////////////////////////////////////
// Deserialization
ShoppingList newList;
TextReader r = new StreamReader( "list.xml" );
newList = (ShoppingList)s.Deserialize( r );
r.Close();
ASKER
Unfortunatly I don't have access to the php code. I am retrieving the array from a database.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Zattz have you tried implementing this yet?
ASKER
Many thanks
What is the data type of the array you want to serialize?
if possible can you post a sample of "Serialized string of that array"?