• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Crystal
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MessagePack implementation in Crystal msgpack.org[Crystal]

MessagePack

Build Status

MessagePack implementation in Crystal.

Installation

Add this to your application's shard.yml:

dependencies:
  msgpack:
    github: crystal-community/msgpack-crystal

Usage

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
# => <House:0x1b06de0 @address="Road12", @location=#<Location:0x1b06dc0 @lat=12.3, @lng=34.5>>

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:0x13f0d80 @address="Something", @location=#<Location:0x13f0d60 @lat=12.3, @lng=34.5>>

house = House.from_msgpack({"address" => "Crystal Road 1234"}.to_msgpack)
p house
# => <House:0x1b06d80 @address="Crystal Road 1234", @location=nil>

More Examples

examples

Msgpack-RPC

implemented by simple_rpc shard

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

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.

More Repositories

1

icr

Interactive console for Crystal programming language
Crystal
502
star
2

crystal-patterns

πŸ“– Examples of GOF patterns written in Crystal
Crystal
294
star
3

jwt

JWT implementation in Crystal
Crystal
205
star
4

crystal-libraries-needed

A list of libraries that are needed or wanted for the Crystal-Language
141
star
5

cossack

Simple and flexible HTTP client for Crystal with middleware and test support.
Crystal
106
star
6

hardware

Get CPU, Memory and Network informations of the running OS and its processes
Crystal
72
star
7

kiwi

A unified Crystal interface for key-value stores.
Crystal
64
star
8

toml.cr

TOML parser for Crystal
Crystal
60
star
9

zeromq-crystal

Crystal
48
star
10

crystal-ann

Web site to announce new Crystal projects, blog posts, updates and other work activities
CSS
45
star
11

leveldb

Crystal binding for LevelDB
Crystal
39
star
12

future.cr

Crystal
34
star
13

bloom_filter

Bloom filter implementation in Crystal lang
Crystal
34
star
14

timecop.cr

A testing library that allows "time travel," "freezing time," and "time acceleration". Inspired by the ruby-timecop library.
Crystal
19
star
15

crystal-kcov

Crystal
17
star
16

autolink.cr

πŸ”— Auto link for Crystal
Crystal
16
star
17

crystal-notifications

A library for notifications, this started as a port from ActiveSupport::Notifications
Crystal
16
star
18

bluetooth

Bluetooth Bluez binding in Crystal
Crystal
10
star
19

cr-config

An all-in-one configuration library to handle any possible configuration need
Crystal
10
star
20

community

The crystal community
10
star
21

snappy-crystal

Snappy bindings for Crystal
Crystal
6
star
22

cr-i18n

Crystal
3
star
23

kilt-components

Crystal
2
star