https://github.com/crystal-community/msgpack-crystal
MessagePack implementation in Crystal msgpack.org[Crystal]
https://github.com/crystal-community/msgpack-crystal
Last synced: 9 months ago
JSON representation
MessagePack implementation in Crystal msgpack.org[Crystal]
- Host: GitHub
- URL: https://github.com/crystal-community/msgpack-crystal
- Owner: crystal-community
- Created: 2015-05-22T11:18:31.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-06-03T20:31:14.000Z (almost 3 years ago)
- Last Synced: 2024-05-06T00:04:50.764Z (almost 2 years ago)
- Language: Crystal
- Homepage:
- Size: 425 KB
- Stars: 133
- Watchers: 8
- Forks: 18
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-crystal - msgpack-crystal - MessagePack library (Network Protocols)
- awesome-crystal - msgpack-crystal - MessagePack library (Network Protocols)
- awesome-crystal - msgpack-crystal - MessagePack library (Network Protocols)
- awesome - crystal-community/msgpack-crystal - MessagePack implementation in Crystal msgpack.org[Crystal] (<a name="Crystal"></a>Crystal)
README
# MessagePack
[](https://github.com/crystal-community/msgpack-crystal/actions/workflows/ci.yml?query=branch%3Amaster+event%3Apush)
MessagePack implementation in Crystal.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
msgpack:
github: crystal-community/msgpack-crystal
```
## Usage
```crystal
require "msgpack"
class Location
include MessagePack::Serializable
property lat : Float64
property lng : Float64
end
class House
include MessagePack::Serializable
property address : String
property location : Location?
end
house = House.from_msgpack({address: "Road12", location: {lat: 12.3, lng: 34.5}}.to_msgpack)
p house
# => >
p house.to_msgpack
# => Bytes[130, 167, 97, 100, 100, 114, 101, 115, 115, 166, 82, 111, 97, 100, ...
house.address = "Something"
house = House.from_msgpack(house.to_msgpack)
p house
# => #>
house = House.from_msgpack({"address" => "Crystal Road 1234"}.to_msgpack)
p house
# =>
```
## More Examples
[examples](https://github.com/benoist/msgpack-crystal/tree/master/examples)
## Msgpack-RPC
[implemented by simple_rpc shard](https://github.com/kostya/simple_rpc)
## Copyright
Copyright 2015 Benoist Claassen
_Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License You may obtain a copy of the License at_
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
_Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License._