DriveWorks Pro 17: 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 data being returned to the constant DWConstantJSON

{
    books: [
    {
         title: "Harry Potter",
         price: 29.99,
     }, {
         title: "Learning JSON",
         price: 39.95
     }]
}
        
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
}
                        

Example Using Text()

Embedding the Text() function withing the path string will return just the values of the element:

RuleMeaning
XPathXMLGet(DWConstantXML, "/bookstore/book/title/text()")Will return Harry Potter|Learning JSON.

This is a pipe delimited list of title element values within all book elements.

XPathXMLGet(DWConstantXML, "/bookstore/book[2]/title/text()")Will return Learning JSON.

This is the title element value within the second ([2]) book element.


See also

This function relates to the Send HTTP Request task.

XPathGet

XPathXMLGet

Table of Contents