serialize

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 6 Imported by: 6

README

go-serialize

Build Status

Golang implementation for PHP's function serialize() and unserialize()

Install / Update

go get -u github.com/techleeone/gophp/serialize

Example

package main

import (
	"fmt"

	"github.com/techleeone/gophp/serialize"
)

func main() {

	str := `a:1:{s:3:"php";s:24:"世界上最好的语言";}`

	// unserialize() in php
	out, _ := serialize.UnMarshal([]byte(str))

	fmt.Println(out) //map[php:世界上最好的语言]

	// serialize() in php
	jsonbyte, _ := serialize.Marshal(out)

	fmt.Println(string(jsonbyte)) // a:1:{s:3:"php";s:24:"世界上最好的语言";}

}

Documentation

Index

Constants

View Source
const UNSERIALIZABLE_OBJECT_MAX_LEN = int64(10 * 1024 * 1024 * 1024)

Variables

This section is empty.

Functions

func Marshal

func Marshal(value interface{}) ([]byte, error)

func MarshalBool

func MarshalBool(value bool) []byte

func MarshalMap

func MarshalMap(value interface{}) ([]byte, error)

func MarshalNil

func MarshalNil() []byte

func MarshalNumber

func MarshalNumber(value interface{}) []byte

func MarshalSlice

func MarshalSlice(value interface{}) ([]byte, error)

func MarshalString

func MarshalString(value string) []byte

func UnMarshal

func UnMarshal(data []byte) (interface{}, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL