GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing php-serialize.com — PHP-Serialize by @steelbrain

PHP-Serialize

serialize and unserialize PHP data structures in JavaScript

Latest ReleaseView on GitHub

Features

PHP Compatibility

Fully compatible with PHP's serialize/unserialize functions for seamless data exchange

Serializable Objects

Support for PHP's Serializable interface with custom class mapping

Type Safety

TypeScript support with strict type checking and comprehensive type definitions

Encoding Options

Flexible encoding options with support for both UTF-8 and binary data

Getting Started

Installation

Choose your preferred package manager:

npm

$ npm install php-serialize

yarn

$ yarn add php-serialize

Basic Usage

import { serialize, unserialize } from 'php-serialize'

// Serialize data
const data = {
  name: 'John Doe',
  age: 30,
  hobbies: ['reading', 'coding']
}
const serialized = serialize(data)

// Unserialize data
const unserialized = unserialize(serialized)
console.log(unserialized) // Original object

Examples

Serializable Objects

class User {
  constructor({ name, age }) {
    this.name = name
    this.age = age
  }
  serialize() {
    return JSON.stringify({ name: this.name, age: this.age })
  }
  unserialize(rawData) {
    const { name, age } = JSON.parse(rawData)
    this.name = name
    this.age = age
  }
}

const user = new User({ name: 'Steel Brain', age: 17 })
const serialized = serialize(user)

// Unserialize with class mapping
const unserialized = unserialize(serialized, { User })
console.log(unserialized instanceof User) // true

Advanced Usage

// Custom namespace mapping
const serializedForNamespace = serialize(user, {
  'MyApp\User': User,
})

// Using different encoding options
const binaryData = serialize(data, {}, { encoding: 'binary' })
const utf8Data = serialize(data, {}, { encoding: 'utf8' })

// Strict mode unserialize
const strict = unserialize(serialized, {}, { strict: true })

Made with ❤️ by Anees Iqbal (@steelbrain)

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.