# class_vs_struct.cr
require "benchmark"
require "json"
TEXT = %({"muffin": false, "test": "Random string!", "user_id" : 1234})
Benchmark.ips do |x|
x.report("json parse") {
json = JSON.parse(TEXT).as_h
if json["muffin"]?
end
}
x.report("from json") {
json = Hash(String, Bool | String | Int32).from_json(TEXT)
if json["muffin"]?
end
}
end