Viewed   215 times

The goal is to unserialize a PHP serialized string and get sutable object in C#

Is there any way to make this possible in C#(.Net)?

To be more specific: We need to make an application which comunicates (Via HTTP) to specific website which returns the needed information. Fortunately/unfortunately we dont have permission to website so the data (array mostly) that is returned from website is PHP serialized.

 Answers

1

Found solution: Sharp Serialization Library

Wednesday, November 16, 2022
2

Use .unserializeSession() instead of .unserialize().

Friday, September 16, 2022
 
shangwu
 
2

I don't know C# but JSON encoding using json_encode() is pretty popular in the web app world as a simple means to transfer simple structures across platforms.

There is a variety of parser classes on the C# end, scroll down in the first link.

Friday, September 23, 2022
 
4

Where do you have the type stored?

Normally you could have something like:

class Document {
    [XmlAttribute("type")]
    public string Type { get; set; }
    [XmlText]
    public string Name { get; set; }
}


public class _Filter    
{
    [XmlElement("Times")]    
    public _Times Times;    
    [XmlElement("Document")]    
    public Document Document;    
}
Friday, December 9, 2022
 
4

It could look like this:

#include <iostream>
#include <sstream>
using namespace std;

int main()
{
    istringstream is("1n2n3n4nn5n");
    string s;
    while (getline(is, s))
    {
        if (s.empty())
        {
            cout << "Empty line." << endl;
        }
        else
        {
            istringstream tmp(s);
            int n;
            tmp >> n;
            cout << n << ' ';
        }
    }
    cout << "Done." << endl;
    return 0;
}

output:

1 2 3 4 Empty line.
5 Done.

Hope this helps.

Saturday, November 5, 2022
 
mikeq
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :