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!

StealthRT
  • 10,108
  • 40
  • 183
  • 342

3 Answers3

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.

Community
  • 1
  • 1
Anton Bessonov
  • 9,208
  • 3
  • 35
  • 38
1

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

Mike Brant
  • 70,514
  • 10
  • 99
  • 103
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!

Hamish
  • 22,860
  • 8
  • 53
  • 67