View Source Machete.JSONMatcher (Machete v0.3.1)

Defines a matcher that matches JSON documents

Summary

Types

t()

Describes an instance of this matcher

Functions

Matches against JSON documents whose deserialization matches a provided matcher

Types

@opaque t()

Describes an instance of this matcher

Functions

@spec json(term()) :: t()

Matches against JSON documents whose deserialization matches a provided matcher

Takes a matcher as its sole (mandatory) argument

Examples:

iex> assert "{}" ~> json(map())
true

iex> assert ~s({"a": 1}) ~> json(%{"a" => 1})
true

iex> assert "[]" ~> json(list())
true

iex> assert "[1,2,3]" ~> json([1,2,3])
true

iex> assert ~s("abc") ~> json(string())
true

iex> assert "123" ~> json(integer())
true

iex> assert "true" ~> json(boolean())
true

iex> assert "null" ~> json(nil)
true