diff --git a/README.md b/README.md index 9f39ba7..a2e74c9 100644 --- a/README.md +++ b/README.md @@ -2,30 +2,6 @@ Command-line tool to encode and decode arbitrary protobuf data. - -## Installation - -This program requires Crystal. See: https://crystal-lang.org/install/ - -### Standalone - -1. Clone: `git clone https://github.com/iv-org/protodec && cd protodec` -2. Build: `crystal build src/protodec.cr` -3. See [Usage](#Usage) below - - -### As a Crystal library - -Add this to your application's `shard.yml`: - -```yaml -dependencies: - protodec: - github: iv-org/protodec - version: ~> 0.1.5 -``` - - ## Usage ``` @@ -81,13 +57,9 @@ $ echo 'CkEKCeOCj+OBn+OBlxDSCSIQWmQ730+N8z8tsp3vp8YJQCoSCAESBzA4MDAwMDAaBQ26sSZE } ``` -## Windows - -Windows users can run the binaries in a linux-on-windows tool (like Git bash or WSL) or use the official [protobuf binaries](https://github.com/protocolbuffers/protobuf/releases) to encode/decode protobuf data. - ## Contributing -1. Fork it () +1. Fork it () 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) diff --git a/shard.yml b/shard.yml index 33c49db..52f911d 100644 --- a/shard.yml +++ b/shard.yml @@ -1,14 +1,13 @@ name: protodec -version: 0.1.5 +version: 0.1.2 authors: - Omar Roth - - Invidous team targets: protodec: main: src/protodec.cr -crystal: ">= 0.34.0, < 2.0.0" +crystal: 0.31.1 license: GPLv3 diff --git a/src/protodec/utils.cr b/src/protodec/utils.cr index 6c7c509..23bcb49 100644 --- a/src/protodec/utils.cr +++ b/src/protodec/utils.cr @@ -213,9 +213,6 @@ module Protodec when "bytes" VarLong.to_io(io, value.size.to_i64) value.as_a.each { |byte| io.write_byte byte.as_i.to_u8 } - else # "string" - VarLong.to_io(io, value.to_s.bytesize.to_i64) - io.print value.to_s end end else @@ -468,7 +465,9 @@ module Protodec Any.new(raw.clone) end - def self.cast_json(object : Hash) + def self.cast_json(object) + raise "Invalid type" if !object.is_a?(Hash) + JSON::Any.new(object.transform_values do |value| case value when .is_a?(Hash)