class Guff::Post def initialize(@row : Hash(String, ::SQLite3::Value)) end def to_json(io) @row.reduce({} of String => String | Array(String)) do |r, k, v| r[k] = v.to_s r end.merge({ "tags": tags }).to_json(io) end private def tags : Array(String) @tags ||= if @row.has_key?("tags") && (@row["tags"] as String).size > 0 (@row["tags"] as String).split('|') else [] of String end end end