postman-collection
postman-collection copied to clipboard
WIP Contextual JSON variable interpolation
This is more of a conversation starter than a solution. I encountered this case when working with the Postman app: A stringified JSON document including other JSON stringified interpolations is recursively evaluated and results in an invalid JSON document (as nested quotes are not properly escaped).
To illustrate the problem, the test case in this PR currently fails as
JSON.parse() would throw the following error:
SyntaxError: Unexpected token f in JSON at position 12
Some ideas:
-
There could be a way to instruct collections to only perform one level of interpolation. Maybe triple curly braces?
-
Given how much JSON is relevant in Postman, there could be a way to interpolate variables in a JSON-aware manner. For example, other systems support a pipe operator where you can transform the content. In this case, we could do something like
{{alpha | escape_json}}
Signed-off-by: Juan Cruz Viotti [email protected]
Codecov Report
Merging #1166 (23d6070) into develop (6174b01) will not change coverage. The diff coverage is
n/a.
@@ Coverage Diff @@
## develop #1166 +/- ##
========================================
Coverage 99.37% 99.37%
========================================
Files 38 38
Lines 2232 2232
Branches 686 686
========================================
Hits 2218 2218
Misses 14 14
| Flag | Coverage Δ | |
|---|---|---|
| unit | 99.37% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 6174b01...23d6070. Read the comment docs.
We have plans to introduce types in variables (this library already supports a few types) but without that, the existing interpolation is a simple string replacement.
Closing stale PRs...