Search with jsonPath? possible?

Hi,
Is it possible to use jsonpath in test (there exist js libraries for it)? because, I do not know the exact path in advance that I have to check. It depends from time to time. The value I need to check can be in element 1 and the next call it can be in element 34.

Capture

I want to use something like this is it possible?

You can use the lodash module that is available in the testing sandbox. The lodash equivalent to the example provided by the jsonPath module would be

var cities = [
  { name: "London", "population": 8615246 },
  { name: "Berlin", "population": 3517424 },
  { name: "Madrid", "population": 3165235 },
  { name: "Rome",   "population": 2870528 }
];

var _ = require('lodash'); // You do not need to require this explicitly in your tests
var names = _.map(cities, 'name');
// name would be
// [ "London", "Berlin", "Madrid", "Rome" ]
2 Likes