+1

On Thu, Oct 20, 2016 at 9:43 PM, Felix Schumacher <
[email protected]> wrote:

> Am 20.10.2016 um 16:31 schrieb Felix Schumacher:
>
>> Am 20.10.2016 16:01, schrieb Roberto Braga:
>>
>>> I think there is a bug in the file
>>>
>>> apache-jmeter-3.0-src/src/components/org/apache/jmeter/extra
>>> ctor/json/jsonpath/JSONPostProcessor.java
>>>
>>>
>>> at line 163, there is the else where i goes if only one match
>>>
>>
>> The below src code is not in sync with the current code.
>>
>> But I think the important step for you is to place an additional var with
>> 'name_1' into vars in the case, when only one element is found and -1 is
>> used to indicate, that all elements are wanted.
>> If you want to update your patch you could have a look at the current
>> trunk and use the function stringify(Object).
>>
> After comparing the current behaviour of JSON Extractor with that of the
> Regex Extractor, I think we should extract to <varname>_1 only, when
> matchNumber is -1 and only one element could be matched.
>
> I have attached a patch and two test cases, that show the behaviour for
> Regex and (modified) JSON Extractor.
>
> Regards,
>  Felix
>
>
>> Regards,
>>  Felix
>>
>>
>>> } else {
>>>
>>>     // else just one value extracted
>>>
>>>     Object obj = extractedValues.get(0);
>>>
>>>     String objAsString =
>>>
>>>             obj != null ? obj.toString() : ""; //$NON-NLS-1$
>>>
>>> *     vars.put(currentRefName, *
>>>
>>> *             objAsString); *
>>>
>>> *     if (matchNumber < 0 && getComputeConcatenation()) {*
>>>
>>> *         vars.put(currentRefName + ALL_SUFFIX, objAsString);*
>>>
>>> *     }*
>>>
>>> }
>>>
>>>
>>> The part which set the vars  is worng it should be like the following:
>>>
>>> } else {
>>>
>>>     // else just one value extracted
>>>
>>>     Object obj = extractedValues.get(0);
>>>
>>>     String objAsString =
>>>
>>>             obj != null ? obj.toString() : ""; //$NON-NLS-1$
>>>
>>> *     if (matchNumber < 0 && getComputeConcatenation()) {*
>>>
>>> *         vars.put(currentRefName + "_1", *
>>>
>>> *                 objAsString);*
>>>
>>> *         vars.put(currentRefName + ALL_SUFFIX, objAsString);*
>>>
>>> *     } else {*
>>>
>>> *         vars.put(currentRefName, *
>>>
>>> *                 objAsString);*
>>>
>>> *     }*
>>>
>>> }
>>>
>>>
>>> In this way it respect the matchNumber docs specification even if only
>>> one value is extracted.
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>



-- 
Cordialement.
Philippe Mouawad.

Reply via email to