0.0.6 • Published 6 years ago

js-php-serialize v0.0.6

Weekly downloads
81
License
MIT
Repository
github
Last release
6 years ago

js-php-serialize

NodeJS Module for working with PHP serialized data

Usage

In the most basic form, simply pass primitives, objects or arrays into the serialize method.

var php = require('js-php-serialize');

console.log(php.serialize({one:"two", 3:"four"}));
// => a:2:{i:3;s:4:"four";s:3:"one";s:3:"two";}

For more complex objects, an optional metadata value can be passed through to provide hints on how to serialize the object. By default this is the __phpSerializedObject__ property, but can be customised by passing through an options object through to the serialize method. (See the __tests__ folder for more examples.)

var php = require('js-php-serialize');

var obj = {
    __phpSerializedObject__: {
        name: "MyCustomClass",
        access: {
            three: "private",
            five: "protected",
        },
    },
    one: "two",
    three: 4,
    five: "six",
};
console.log(php.serialize(obj));
// => O:13:"MyCustomClass":3:{s:3:"one";s:3:"two";s:20:"MyCustomClassthree";i:4;s:7:"*five";s:3:"six";}
0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago