0

I'm using NeoLoad 6.3.1 at the moment and am trying to get the length of an array where the array itself is the root element.

Given the following sample JSON:

[
  { "id": 1, "title": "Item 1" },
  { "id": 2, "title": "Item 2" },
  { "id": 3, "title": "Item 3" },
  { "id": 4, "title": "Item 4" },
  { "id": 5, "title": "Item 5" }
]

I want to just get back the answer of "5".

If I use the JSON Path Online Evaluator, I can use $.length and it returns:

[ 5 ]

In NeoLoad 6.3.1, that returns an error.

As NeoLoad is Java-based, I am assuming that they're using the com.jayway.jsonpath's json-path library (or something similar). Based on the documentation there I updated the query to be $.length() but did not have any luck.

Any suggestions?

3
  • NeoLoad as a library (and Java as a language) has its own defined rules - it is not a valid assumption to equate these with "online path evaluator I found" or "some other library" without further evidence. Honor NeoLoad (and Java) in their own right, utilizing the respective documentation. There is currently no shown code that "returns an error". It is important, because in such questions it is often that [unshown user] code that is wrong in context; even if this code is "valid" in a large context, such can't even be argued for because it's not shown. Commented Feb 21, 2018 at 18:34
  • That's why I mentioned I updated my path expression to follow the documentation from Jayway JSON Path library for Java. Commented Feb 21, 2018 at 18:39
  • And still no code/context .. the beliefs in what is used or how something "should work" are simply beliefs. They can be turned into hypothesis and tested. Repeat the cycle until there is agreement. The documentation (and even scouring implementation) can provide insight. Commented Feb 21, 2018 at 18:39

1 Answer 1

2

In Neoload, there is "Variable Extractor" action where you can provide left boundary, right boundary for any one of the subnode in your array. e.g. LB:"title": " RB: " } and select "extract call occurrences" option. This variables can be accessed via "variablename_matchNr" which gives count of all occurrences of given extraction. Better explained here: http://answers.neotys.com/questions/590268-created-variable-extractor-last-occurrence-extracted-values

Neload also provides JSON path expression in variable extractor where user can select any one node and select "extract call occurrences". Neoload variable extractor

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.