The JSON Path Extractor element

Another helpful nugget in the JMeter plugin's project is the JSON Path Extractor element. This makes working with JSON pure bliss. It helps extract data out of a JSON response using JSONPath syntax (http://goessner.net/articles/JsonPath/index.html#e2). For complex JSON structures, using JMeter's bundled XPath Extractor can sometimes lead to heartache when trying to get at targeted elements. Where XPath Extractor fails, JSON Path Extractor shines.

Consider a JSON structure like the following:

{ "store": { 
    "book": [  
{ "category": "reference", 
        "author": "Nigel Rees", 
        "title": "Sayings of the Century", 
        "price": 8.95 
      }, 
{ "category": "fiction", 
        "author": "Evelyn Waugh", 
        "title": "Sword of Honour", 
        "price": 12.99 
      }, 
{ "category": "fiction", 
        "author": "Herman Melville", 
        "title": "Moby Dick", 
        "isbn": "0-553-21311-3", 
        "price": 8.99 
      }, 
{ "category": "fiction", 
        "author": "J. R. R. Tolkien", 
        "title": "The Lord of the Rings", 
        "isbn": "0-395-19395-8", 
        "price": 22.99 
      } 
    ], 
    "bicycle": { 
      "color": "red", 
      "price": 19.95 
    } 
  } 
}

If you want to get to the title of the second book in the store, an expression like $.store.book[1].title will get you there swiftly. No matter how nested the structure is, JSON Path Extractor gets the job done elegantly. Refer to the two examples that accomplish this in this book: JSONPathExtractorExample.jmx (from the JMeter plugin's site) and dummy-sampler.jmx.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.5.68