-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extracting json using extract_binds returns unicode string #77
Comments
Ah, I think I understand your confusion here. The MiniJsonExtractor parses JSON before doing extraction, so if you're extracting a full data structure (a list or dictionary), it returns a python object, not a text string. When used in a template, this may give unexpected results. There's a couple solutions to this problem:
A little clunkier I know, but usable.
Does that both answer your question and give some idea of where future options are going? |
@night2tl Your voice has been heard: this is addressed explicitly in the next release by enhanced templating support in #93 (scoped/dynamic templating... dynamic, in this case). Since I haven't heard any more feedback on this one, I'm going to go ahead and close it as a duplicate of the larger featureset. |
I tried creating a custom extractor named jsonpath_mini_string in validators.py. So you can just call
and variable $sessionId refers later in template will be pure json string but not unicode. Rename this attachment to validators.py and replace with original file in pyresttest install path. |
when using something like this:
- extract_binds:
- 'myJson': {'jsonpath_mini': 'json_field'}
Instead of returning an escaped answer like {"access":"asdasd"},
it returns a unicode one : {u'access': u'asdasd'}
when referred to in other context as $myJson.
Which makes it incorrect for further usage in latter requests.
The text was updated successfully, but these errors were encountered: