Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document additional usage of json resource #3737

Merged
merged 2 commits into from Jan 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/resources/json.md.erb
Expand Up @@ -47,6 +47,21 @@ where
* `name` is a configuration setting in a JSON file
* `should eq 'foo'` tests a value of `name` as read from a JSON file versus the value declared in the test

The `json` resource can also be used with JSON formatted output from a command.
Using the same JSON as the previous example, it can be queried using:

describe json({ command: 'retrieve_data.py --json'}) do
its('name') { should eq 'hello' }
its(['meta','creator']) { should eq 'John Doe' }
its(['array', 1]) { should eq 'one' }
end

Finally, content can be passed directly to the resource:

describe json({ content: '{\"item1\": { \"status\": \"available\" } }' }) do
its(['item1', 'status']) { should cmp 'available' }
end

<br>

## Examples
Expand All @@ -70,4 +85,3 @@ The `name` matcher tests the value of the filename as read from a JSON file vers
## Matchers

For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).