jq v1.0.2 JQ View Source
Provides capability to run jq queries on elixir structures. jq docs
Examples
iex> JQ.query(%{key: "value"}, ".key")
{:ok, "value"}
iex> JQ.query!(%{key: "value"}, ".key")
"value"
Link to this section Summary
Link to this section Functions
Link to this function
query(payload, query, options \\ []) View Source
Execute a jq query on an elixir structure.
Internally invokes JQ.query!/3 and rescues from all exceptions.
If a JQ.NoResultException is raised, {:ok, nil} is returned
Link to this function
query!(payload, query, options \\ []) View Source
Execute a jq query on an elixir structure.
payloadis any elixir structurequerya jq query as a string
Internally this function encodes the payload into JSON, writes the JSON to
a temporary file, invokes the jq executable on the temporary file with the supplied
jq query.
The result is then decoded from JSON back into an elixir structure.
The temporary file is removed, regardless of the outcome. System.cmd/3 is called
with the :stderr_to_stdout option.
Options
:max_byte_size- integer representing the maximum number of bytes allowed for the payload, defaults tonil.
Error reasons
JQ.MaxByteSizeExceededException- when the byte_size of the encoded elixir structure is greater than the:max_byte_sizevalueJQ.SystemCmdException- when System.cmd/3 returns a non zero exit codeJQ.NoResultException- when no result was returnedJQ.UnknownException- when System.cmd/3 returns any other error besides those already handledPoison.EncodeError- when there is an error encodingpayloadPoison.DecodeError- when there is an error decoding the jq query resultTemp.Error- when there is an error creating a temporary fileFile.Error- when there is an error removing a temporary file