Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uNetworking/SuperCereal
Faster JSON serialization for Golang
https://github.com/uNetworking/SuperCereal
fast json serializer
Last synced: 8 days ago
JSON representation
Faster JSON serialization for Golang
- Host: GitHub
- URL: https://github.com/uNetworking/SuperCereal
- Owner: uNetworking
- License: zlib
- Created: 2017-07-21T09:31:46.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-29T07:16:15.000Z (over 5 years ago)
- Last Synced: 2024-08-01T13:30:36.075Z (3 months ago)
- Topics: fast, json, serializer
- Language: Go
- Homepage:
- Size: 142 KB
- Stars: 61
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**SuperCereal** is a simple and efficient JSON serialization library for Go. Unlike most other serializers, including Go's `json.Marshal` and JavaScript's `JSON.stringify`, it doesn't operate using an intermediary tree data structure. This makes it significantly more efficient in both time and memory. Because it doesn't use third-party non-standard preprocessing, your code remains purely standard & portable Golang.
## 17x the json.Marshal performance
```go
supercereal.Marshal(func(object *supercereal.Object) {
object.Put("firstName", "John")
object.Put("lastName", "Smith")
object.Put("isAlive", true)
object.Put("age", 25)
object.Put("address", func(object *supercereal.Object) {
object.Put("streetAddress", "21 2nd Street")
object.Put("city", "New York")
object.Put("state", "NY")
object.Put("postalCode", "10021-3100")
})
object.Put("phoneNumbers", func(array *supercereal.Array) {
array.Put(func(object *supercereal.Object) {
object.Put("type", "home")
object.Put("number", "212 555-1234")
})
array.Put(func(object *supercereal.Object) {
object.Put("type", "office")
object.Put("number", "646 555-4567")
})
array.Put(func(object *supercereal.Object) {
object.Put("type", "mobile")
object.Put("number", "123 456-7890")
})
})
object.Put("children", func(array *supercereal.Array) {})
object.Put("spouse", nil)
})
```Where `supercereal.Marshal` returns the `[]byte` (here prettified for demonstration):
```json
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
},
{
"type": "mobile",
"number": "123 456-7890"
}
],
"children": [],
"spouse": null
}
```*Licensed Zlib © 2017 - 2019*