[Feature Request] Reference another JSON object as an environment variable
See original GitHub issue- Insomnia Version: 5.14.9
- Operating System: Ubuntu 17.10
Details
When defining base and sub environments you’re unable to dump a raw variable to return a JSON object.
For example, the following environment results in an Unexpected token { in JSON at position 286
error:
{
"addresses": {
"home": {
"line1": "123 E Fake Street",
"city": "Nowheresville",
"state": "AL",
"zip_code": "12345"
},
"work": {
"line1": "123 E Fake Street",
"city": "Nowheresville",
"state": "AL",
"zip_code": "12345"
}
},
"people": {
"name": "John Pinkerton",
"phone_number": "123-456-7890",
"address": {{ addresses.home | dump }}
}
}
The problem is specific to the {{ addresses.home | dump }}
variable. I don’t get the error if I surround the variable in quotes but then it is treated as a string instead of an object. The same variable works fine in a request body.
EDIT: If it wasn’t obvious the expected behavior is that {{ addresses.home | dump }}
would parse out to the full JSON object:
{
"line1": "123 E Fake Street",
"city": "Nowheresville",
"state": "AL",
"zip_code": "12345"
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
[Feature Request] Reference another JSON object as ... - GitHub
The reason that it doesn't work currently is that the environment is stored as a JSON object on the database model and request...
Read more >Proper Ways to Pass Environment Variables in JSON for ...
TL;DR. The best practice is using a data generation function. Scrolling to the bottom for the detail. Setup a mock API server for...
Read more >How to work with JSON objects and variables in Postman
Hey guys, in this short live video I wanted to show you how you can work with objects and variables in Postman.
Read more >JSON Reference — JSON Spec documentation - Read the Docs
JSON Reference allows a JSON value to reference another value in a JSON document. This module implements utilities for exploring these objects.
Read more >How to include an environment variable in a json file?
Simply define the profile value to be relative to the user's home directory if it is not an absolute path. But really, you've...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I see. Thanks for the example 😄
At this moment, plugins aren’t able to modify the environment (only read it). But, if this functionality were added, you could write a simple plugin that looked at your environment and built these objects for you.
For example:
Then, a plugin could look through the array and replace the
cheeseburger_combo
array with the full-constructed object before the request is made.Just an idea for the future.
FYI, I Just published the plugin under
insomnia-plugin-jsonpath
if you want to try it out.