Code Monkey home page Code Monkey logo

Comments (11)

kostya avatar kostya commented on August 15, 2024

array_of_hash.to_msgpack ?

or by hands

[1, {1 => 2}]

packer.write_array_start(2)
packer.write(1)
packer.write_hash_start(1)
packer.write(1)
packer.write(2)

from msgpack-crystal.

benoist avatar benoist commented on August 15, 2024

I think the JSON::Any is throwing the error

from msgpack-crystal.

benoist avatar benoist commented on August 15, 2024

And the slice

from msgpack-crystal.

waghanza avatar waghanza commented on August 15, 2024

@kostya seems not to work since I have to overloead matches
@benoist new to crystal and compiled language, could you explain plz

from msgpack-crystal.

benoist avatar benoist commented on August 15, 2024

Welcome to crystal :-). The array of hashes has got values of type JSON::Any and Slice(UInt8) which msgpack does not know how to convert.
You can see the type of array_of_hashes by calling .class on it. It should fit the MessagePack::Type.

from msgpack-crystal.

waghanza avatar waghanza commented on August 15, 2024

@benoist type is Array(Hash(String, Nil | String | Float32 | Float64 | Time | JSON::Any | Bool | Int32 | Int64 | Int16 | Slice(UInt8)))
array_of_hashes contain array of hash (String,String)

but type overload seem not te be available

from msgpack-crystal.

benoist avatar benoist commented on August 15, 2024

Yes that's what I thought. There are two types that can't be MessagePacked. So either remove them from the hash or convert them to a supported type in the MessagePack::Type alias

from msgpack-crystal.

waghanza avatar waghanza commented on August 15, 2024

@benoist and what message pack could convert ?
String an Int ?

from msgpack-crystal.

benoist avatar benoist commented on August 15, 2024

MessagePack::Type = Nil | Bool | Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64 | Float32 | Float64 | String | Array(Type) | Hash(Type, Type)

from msgpack-crystal.

benoist avatar benoist commented on August 15, 2024

Did you manage to do what you wanted?

from msgpack-crystal.

waghanza avatar waghanza commented on August 15, 2024

no, I have temporarily left msgpack (I' use json as my app is unstable)

from msgpack-crystal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.