JSON & JSONPath
JSON & JSONPath
WWW.PAVANONLINETRAININGS.COM
What is JSON?
WWW.PAVANONLINETRAININGS.COM
JSON Data Types
▪ Number
▪ String
▪ Boolean
▪ Null
▪ Object
▪ Array
WWW.PAVANONLINETRAININGS.COM
Data Types
▪ String
▪ Strings in JSON must be written in double quotes.
▪ Example:
{ "name":"John" }
▪ Numbers
▪ Numbers in JSON must be an integer or a floating point.
▪ Example:
{ "age":30 }
▪ Object
▪ Values in JSON can be objects.
▪ Example:
{
"employee":{ "name":"John", "age":30, "city":"New York" }
}
WWW.PAVANONLINETRAININGS.COM
Data Types
▪ Array
▪ Values in JSON can be arrays.
▪ Example:
{
"employees":[ "John", "Anna", "Peter" ]
}
▪ Boolean
▪ Values in JSON can be true/false.
▪ Example:
{ "sale":true }
▪ Null
▪ Values in JSON can be null.
{ "middlename":null }
WWW.PAVANONLINETRAININGS.COM
JSON - Syntax
WWW.PAVANONLINETRAININGS.COM
JSON vs XML
WWW.PAVANONLINETRAININGS.COM
Examples
WWW.PAVANONLINETRAININGS.COM
JSON Object & JSON Array
WWW.PAVANONLINETRAININGS.COM
JSON Object
▪ JSON object holds key/value pair. Each key is represented as a string in JSON
and value can be of any type.
▪ The keys and values are separated by colon. Each key/value pair is separated
by comma.
▪ Example:
WWW.PAVANONLINETRAININGS.COM
▪ JSON Object with Strings ▪ JSON Object with Numbers
{ {
"name": "Scott", "integer": 34,
"email": "[email protected]" "fraction": .2145,
"exponent": 6.61789e+0
} }
WWW.PAVANONLINETRAININGS.COM
JSON Array
▪ JSON array can store multiple values. It can store string, number, boolean or
object in JSON array.
WWW.PAVANONLINETRAININGS.COM
JSON Array of Strings
["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
WWW.PAVANONLINETRAININGS.COM
WWW.PAVANONLINETRAININGS.COM
Capture & Validate JSON Path
https://jsonpathfinder.com/
https://jsonpath.com/
WWW.PAVANONLINETRAININGS.COM