Last active
June 11, 2020 20:56
-
-
Save ellcs/a957cf4a1c0dc51d9221076bf96e2012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://crystal-lang.org/api/0.22.0/JSON.html | |
# online repl: https://play.crystal-lang.org/#/r/995s | |
require "json" | |
value = JSON.parse("[1, 2, 3]").raw # : JSON::Any | |
# (Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil) | |
typeof(value) | |
if value.is_a?(Array) | |
puts typeof(value) # Array(JSON::Any) | |
elsif value.is_a?(Hash) | |
puts typeof(value) # Hash(JSON::Any) | |
elsif value.is_a?(Int64) | |
puts "int" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment