Skip to content

Instantly share code, notes, and snippets.

@fujimura
Last active January 1, 2016 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujimura/74857bfd1148c23fd27a to your computer and use it in GitHub Desktop.
Save fujimura/74857bfd1148c23fd27a to your computer and use it in GitHub Desktop.
def json_include x, y
case x
when Hash
return false unless y.is_a? Hash
y.all? { |k, v| json_include(x[k], v) }
when Array
return false unless y.is_a? Array
y.all? { |y_| x.any? { |x_| json_include(x_, y_) } }
else
x == y
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment