forked from hprose/hprose-golang
/
formatter.go
42 lines (37 loc) · 1.52 KB
/
formatter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* io/formatter.go *
* *
* io Formatter for Go. *
* *
* LastModified: Dec 3, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
package io
// Serialize data
func Serialize(v interface{}, simple bool) []byte {
return NewWriter(simple).Serialize(v).Bytes()
}
// Marshal data
func Marshal(v interface{}) []byte {
return Serialize(v, true)
}
// Unserialize data
func Unserialize(b []byte, p interface{}, simple bool) {
reader := AcquireReader(b, simple)
defer ReleaseReader(reader)
reader.Unserialize(p)
}
// Unmarshal data
func Unmarshal(b []byte, p interface{}) {
Unserialize(b, p, true)
}