I am using chef inspec to validate in the below json file whether annotation is equal to Test.
"imdata": [
{
"aaaPwdStrengthProfile": {
"attributes": {
"annotation": "Test",
}
}
}
]
Trying with the below script but getting error
describe json('C:/output.json') do
its(['imdata','aaaPwdStrengthProfile','attributes','annotation']) { should eq 'Test' }
end
In the JSON file you are trying to test, imdata
is an array []
. The nested dictionary { .. }
is the first element (0) of that array.
I created the JSON data from your question as /tmp/sample.json
. So the inspec test should refer to 'imdata', 0,
, like below:
describe json('/tmp/sample.json') do
its(['imdata', 0, 'aaaPwdStrengthProfile', 'attributes', 'annotation']) { should eq 'Test' }
end