Write JSON::Any

remotes/dev/pr-multi
Karchnu 2020-11-13 22:41:18 +01:00
parent b0c62f89c8
commit 3c82ed329f
1 changed files with 6 additions and 0 deletions

View File

@ -1,3 +1,5 @@
require "json"
class CBOR::Encoder
def self.new(io : IO = IO::Memory.new)
packer = new(io)
@ -8,6 +10,10 @@ class CBOR::Encoder
def initialize(@io : IO = IO::Memory.new)
end
def write(j : JSON::Any)
write j.raw
end
def write(value : Nil | Nil.class, use_undefined : Bool = false)
write(use_undefined ? SimpleValue::Undefined : SimpleValue::Null)
end