From 3c82ed329f406ca5fdf49547ddcc3298957fdd56 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Fri, 13 Nov 2020 22:41:18 +0100 Subject: [PATCH] Write JSON::Any --- src/cbor/encoder.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cbor/encoder.cr b/src/cbor/encoder.cr index 65e5e63..92678b4 100644 --- a/src/cbor/encoder.cr +++ b/src/cbor/encoder.cr @@ -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