According to the json_path tests, this is how to get an array:
(at-path "$.foo[*]" {:foo ["a", "b", "c"]}) => ["a", "b", "c"]
Whenever I select an element that is an array, it looks like the verify-document function calls verify-clause on each of the elements, checking if the element is of type array, which it isn't.
Output:
$ java -jar janus-0.0.2-standalone.jar --verify myservice.jns
verify-document: doc {"links":[{"href":"http://myservice.example.com/v3/channels","rel":"channels"},{"href":"http://config.example.com/v1/","rel":"config"},{"href":"http://myservice.example.com/v3/","rel":"self"}]} clauses ([:path $.links[*] :of-type :array])
verify-seq: actual-seq [{:href http://myservice.example.com/v3/channels, :rel channels} {:href http://config.example.com/v1/, :rel config} {:href http://myservice.example.com/v3/, :rel self}] clause [:path $.links[*] :of-type :array]
verify-clause: value {:href http://myservice.example.com/v3/channels, :rel channels} clause [:path $.links[*] :of-type :array]
of-type: actual {:href http://myservice.example.com/v3/channels, :rel channels}
verify-clause: value {:href http://config.example.com/v1/, :rel config} clause [:path $.links[*] :of-type :array]
of-type: actual {:href http://config.example.com/v1/, :rel config}
verify-clause: value {:href http://v3/, :rel self} clause [:path $.links[*] :of-type :array]
of-type: actual {:href http://myservice.example.com/v3/, :rel self}
1 service (1 failed)
My Service:
root resource:
Expected "{:href "http://myservice.example.com/v3/channels", :rel "channels"}" to be array, at path $.links[*]
Expected "{:href "http://config.example.com/v1/", :rel "config"}" to be array, at path $.links[*]
Expected "{:href "http://myservice.example.com/v3/", :rel "self"}" to be array, at path $.links[*]
myservice.jns:
(service
"My Service"
(contract "root resource"
(method :get)
(url "http://myservice.example.com/v3/?param1=a¶m2=24")
(header "Accept-Language" "en_US")
(header "Accept" "application/json")
(should-have :path "$.links[*]" :of-type :array)))
Response:
{
"links": [
{
"href": "http://myservice.example.com/v3/channels",
"rel": "channels"
},
{
"href": "http://config.example.com/v1/",
"rel": "config"
},
{
"href": "http://myservice.example.com/v3/",
"rel": "self"
}
]
}
According to the json_path tests, this is how to get an array:
Whenever I select an element that is an array, it looks like the
verify-documentfunction callsverify-clauseon each of the elements, checking if the element is of type array, which it isn't.Output:
myservice.jns:
Response:
{ "links": [ { "href": "http://myservice.example.com/v3/channels", "rel": "channels" }, { "href": "http://config.example.com/v1/", "rel": "config" }, { "href": "http://myservice.example.com/v3/", "rel": "self" } ] }