Importance Of JSONPath | JSONPath Vs XPath | Retrieve Data Using JSONPath Expressions
Agenda:
1) What is JSONPath
2) Difference between JSONPath and XPath
3) JSONPath & XPath Expressions and Syntax
4) How retrieve data from JSON using JSON Path
Practical Demo
1) What is JSONPath
- JSONPath is a query language for the JSON, similar to XPATH for XML.
- JSONPath uses special notation to represent nodes and their connections to adjacent nodes in a JSONPath.
- There are two styles of notation and they are same, namely
- Bracket : $[‘store’][‘book’][0][‘author’]
- Dot : $.store.book[0].author
- Where, The dollar sign ($) represents root member object
2) Difference between JSONPath and XPath
JSONPath :
- JSONPath expressions always refer to a JSON structure
- Square brackets in JSONPath operate on the object or array addressed by the previous path fragment
- Indices always start by 0
- E.g : $.store.book[*].author
- Currently only single quotes allowed inside of JSONPath expressions
XPath :
- XPath expression are used in combination with an XML document
- Square brackets in XPath expressions always operate on the node set resulting from the previous path fragment
- Indices always start by 1
- E.g : /store/book/author
- In XPath you can use either single or double quotes
3) JSONPath & XPath Expressions and Syntax
JSONPath
|
XPath
|
Description
|
$
|
/
|
The root object/element
|
@
|
.
|
The current object/element
|
. Or []
|
/
|
Child operator
|
..
|
//
|
Recursive descent
|
*
|
*
|
Wildcard
|
[]
|
[]
|
Subscript operator
|
?()
|
[]
|
Filter (script) expression
|
n/a
|
()
|
Grouping in XPath
|
4) How retrieve data from JSON using JSON Path
Practical Demo :
- Guys for this demo have created a video on youtube channel, to watch click on below URL or on image mentioned above.
Practical Demo URL : https://youtu.be/0CvAfD9YNq8
Thanks,
The Tech HelpLine Team :)
Email ID : jobsmails18@gmail.com
Facebook Channel : https://www.facebook.com/pg/Tech-HelpLine-107359517579302
YouTube Channel : https://www.youtube.com/channel/UCFCIUqpwCMl4i7Lqtovz_cQ
Comments
Post a Comment