Online PHP and JSON Unserializer

Clear


                            
                        
Description our online service and tips for use unserialize()

As you can see from the title, on this page you can convert json or serialize string to variable using json_decode and unserialize functions. The program will automatically check type of your string json or serialize it should be processed. The result can be deduced in several ways, with a more or less reportable description. The result will appear on the same page under the form after you click to "Unserialize" button.

We also want to write a few tips that can help you if you get errors while using the unserialize function.

This is the most common mistake that occurs when trying to do unserialize for string

[ Notice ]: unserialize(): Error at offset 15 of 325 bytes

First, if your serialized string contains atypical characters, such as Cyrillic or other languages, as an example, such letters may cause errors: ä, ö, Ї. If there are such letters in your line and you have received an error for its decision you can pass the lines before sending string to unserialize() through such preg_replace_callback() function

$string = preg_replace_callback(
    '!s:(\d+):"(.*?)";!s',
    function($m){
        $len = strlen($m[2]);
        $result = "s:$len:\"{$m[2]}\";";
        return $result;
    },
    $string
);

The second hint will be to check the quotes that are in your string.

As an example this string have problem with quotes, there are unclosed last double quotes in empty values

a:2:{i:0;s:10:"Vegetables";s:6:"Fruits";a:2:{i:0;s:5:"Apple";i:1;s:0:";}}

This will be the correct version of this string.

a:2:{i:0;s:10:"Vegetables";s:6:"Fruits";a:2:{i:0;s:5:"Apple";i:1;s:0:"";}}

Thanks for reading, we hope our online service Php and Json Unserializer will be useful for you and tips will help solve some problems with unserialize.