Home Search

DriveWorks Pro 22
XPathJsonGet

Send Feedback

XPathJsonGet

Finds the value at a given path in a JSON string.

Syntax

XPathJsonGet([Input Data],[Path])

Where:

Input Data is the input data on which to search.

Path is the path to find in the given data object.

Examples

Example JSON

The examples below use the following JSON data stored in a constant.

{
    "books": [
     {
         "title": "Harry Potter",
         "price": 29.99,
     }, 
     {
         "title": "Learning JSON",
         "price": 39.95
     }
   ]
}
        

Examples

The examples below show JSON data stored in a constant being parsed with XPathJsonGet() using a path expression.

RuleMeaning
XPathJsonGet(DWConstantJSON,"books")Will return...
[
    {
        "title":"Harry Potter",
        "price":29.99},
    {
        "title":"Learning JSON",
        "price":39.95
    }
]                        
XPathJsonGet(DWConstantJSON,"books[0]")Will return...
{
        "title":"Harry Potter",
        "price":29.99
}                        
XPathJsonGet(DWConstantJSON,"books[0].title")Will return...
Harry Potter                        
XPathJsonGet(DWConstantJSON,"books[?(@.price > 30.00)]")Will return...
{
        "title":"Learning JSON",
        "price":39.95
}                        
XPathJsonGet(DWConstantJSON,"$.books[*].price")Will return...
[
        29.99,
        39.95
]                        
XPathJsonGet(DWConstantJson,"books[?(@.title == 'Learning JSON')]")Will return...
{
        "title":"Learning JSON",
        "price":39.95
}                        


See also

This function relates to the Send HTTP Request task.

XPathGet

XPathXMLGet