mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-23 09:44:22 +03:00
Add jsonpath Test
This commit is contained in:
parent
df6a8f8a8b
commit
a4df7f79a0
@ -105,9 +105,27 @@
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.[?(@.id == 1)].name"</span> <span class="filter-type">nth</span> <span class="number">0</span> <span class="predicate-type">==</span> <span class="string">"Bob"</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$[?(@.id == 1)].name"</span> <span class="filter-type">nth</span> <span class="number">0</span> <span class="predicate-type">==</span> <span class="string">"Bob"</span></span>
|
||||
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/assert-json/filter</span></span>
|
||||
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
||||
<span class="line"><span class="section-header">[Asserts]</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.fruit[?(@.price.US==200)].name"</span> <span class="filter-type">nth</span> <span class="number">0</span> <span class="predicate-type">==</span> <span class="string">"grape"</span></span>
|
||||
<span class="line"><span class="query-type">jsonpath</span> <span class="string">"$.fruit.[?(@.US == 100)]"</span> <span class="filter-type">count</span> <span class="predicate-type">==</span> <span class="number">0</span></span> <span class="comment"># To be clarified with spec: the first fruit is return by jsonpath.com</span>
|
||||
<span class="json"><span class="line">{</span>
|
||||
<span class="line"> "fruit": [</span>
|
||||
<span class="line"> {</span>
|
||||
<span class="line"> "name": "apple",</span>
|
||||
<span class="line"> "price": {</span>
|
||||
<span class="line"> "US": 100,</span>
|
||||
<span class="line"> "UN": 110</span>
|
||||
<span class="line"> }</span>
|
||||
<span class="line"> },</span>
|
||||
<span class="line"> {</span>
|
||||
<span class="line"> "name": "grape",</span>
|
||||
<span class="line"> "price": {</span>
|
||||
<span class="line"> "US": 200,</span>
|
||||
<span class="line"> "UN": 150</span>
|
||||
<span class="line"> }</span>
|
||||
<span class="line"> }</span>
|
||||
<span class="line"> ]</span>
|
||||
<span class="line">}</span></span>
|
||||
</span></span></code></pre>
|
||||
|
@ -105,8 +105,26 @@ jsonpath "$[0].name" == "Bob"
|
||||
jsonpath "$.[?(@.id == 1)].name" nth 0 == "Bob"
|
||||
jsonpath "$[?(@.id == 1)].name" nth 0 == "Bob"
|
||||
|
||||
|
||||
GET http://localhost:8000/assert-json/filter
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
jsonpath "$.fruit[?(@.price.US==200)].name" nth 0 == "grape"
|
||||
jsonpath "$.fruit.[?(@.US == 100)]" count == 0 # To be clarified with spec: the first fruit is return by jsonpath.com
|
||||
{
|
||||
"fruit": [
|
||||
{
|
||||
"name": "apple",
|
||||
"price": {
|
||||
"US": 100,
|
||||
"UN": 110
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "grape",
|
||||
"price": {
|
||||
"US": 200,
|
||||
"UN": 150
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user