1

I have this value under Items in my DB:

a:1:{i:0;a:9:{s:12:"model_number";s:10:"TT1-W";s:5:"price";s:4:"3810";s:10:"unit_price";d:3135.6300000000001091393642127513885498046875;s:8:"id_price";d:3810;s:9:"sales_tax";d:290.3700000000000045474735088646411895751953125;s:5:"sales";d:3084.6300000000001091393642127513885498046875;s:7:"service";s:2:"51";s:7:"freight";s:3:"384";s:13:"co_cat";s:3:"X4";}}

Making it more reader-friendly:

a:1:
    {
    i:0;
    a:9:
        {
        s:12:"model_number";
        s:10:"TT1-W";
        s:5:"price";
        s:4:"3810";
        s:10:"unit_price";
        d:3135.6300000000001091393642127513885498046875;
        s:8:"id_price";
        d:3810;
        s:9:"sales_tax";
        d:290.3700000000000045474735088646411895751953125;
        s:5:"sales";
        d:3084.6300000000001091393642127513885498046875;
        s:7:"service";
        s:2:"51";
        s:7:"freight";
        s:3:"384";
        s:13:"co_cat";
        s:3:"X4";
        }
    }

I am unable to find out how to decode this string since it can not seem to find reference to it in the php code that displays it on the page. It looks to me to be JSON but i can not seem to find a "standard" format for the above in order to start figuring out where it starts and where it ends.

I am needing this to be decoding using ASP.net. But then again, i need to figure out what it is before i can start decoding it!

Any help to what it is would be great!

5
  • Have you tried json_decode()? Commented Aug 13, 2012 at 20:46
  • @Matt That is not JSON, just similar looking. Commented Aug 13, 2012 at 20:47
  • Wait, do you need help with ASP.net or PHP? Commented Aug 13, 2012 at 20:47
  • @Matt: I need it decoded for ASP.net. It's currently in PHP. Commented Aug 13, 2012 at 20:48
  • Still needing to find out how to decode this using VB.net/ASP.net :o) Commented Aug 16, 2012 at 3:44

3 Answers 3

2

Try with unserialize: function.unserialize

EDIT: If you can use C# libraries: How to unserialize PHP Serialized array/variable/class and return suitable object in C#

EDIT2: Visual Studio Tip: Three ways to use C# within a VB.NET project

EDIT3:

i need to figure out what it is

It's standard PHP-solution to store (and restore) arrays and objects (and other types, see manual) in strings.

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

1 Comment

Any way to unserialize in ASP.net?
1

That appears to be PHP's serialization methodology. You just need to use PHP's unserialize() on it.

2 Comments

Any way to unserialize in ASP.net?
There may be some library or code snippet available to unserialize PHP in ASP.net, you would just need to Google. I don't work in ASP, so I can't give you any suggestions.
1

This looks a serialized object. PHP's unserialize is probably what you want:

unserialize() takes a single serialized variable and converts it back into a PHP value.

There is no built in way to turn that into an ASP.Net object, but it is a regular format, so you can build your own parser to create a simple dictionary representation of the attributes of that particular structure.

But if you're trying to de-serialize a PHP object in ASP.Net you're probably doing something wrong!

2 Comments

We are converting an old CMS thats written in PHP over to asp.net so we dont really have a choice. :o)
Fun times! Ok, well looks like Anton has given you some good tips then. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.