module Main
  class ClassUnit < Jsonable
    attr_reader :id, :name

    def initialize(id:, name:)
      @id = id
      @name = name
    end
  end
end
require "oj"

module Main
  class ClassUnit

    def initialize(id:, name:)
      @hash = {}
      @hash[:Id] = id if id
      @hash[:Name] = name if name
    end

    def to_hash
      @hash
    end

    def to_json
      Oj.dump(@hash)
    end
  end
end
Speed up encoding to json
[roda][ClassUnit] Speed up encoding to json
