Fix interpolation with Objects and Arrays
Description
Fixes: #1910 & #1635
Update how variable interpolation works, so the behavior with objects and arrays is more as expected.
- Interpolation of objects and arrays now works
- Try to use the default
toString-Method if available- Except for the default Object and arrays
Test collection: https://cdn.discordapp.com/attachments/693228572286124085/1221951301404065873/json-testing_2.zip?ex=661471d5&is=6601fcd5&hm=277420a68a493567de437403f133622d186642f689e761d0438306b7579497ad&
Before:
After:
Pre-Build binary with the fix: https://github.com/Its-treason/bruno/releases/tag/nightly
Hmm... I'm a bit confused that for string interpolation, you have to put double-quotes into the string yourself ("{{my_string}}"), but for arrays and objects, you don't have to put [ ] and { } around them.
Of course, fixing this by removing the need to put " around the string would break backwards-compatibility in a really bad way, and it would break otherwise needed functionality where you just want to plop a raw string into some body. (I sometimes need to send invalid JSON as part of my tests).
The more I think about this: Trying to solve serialization for the user is really tricky. Whatever we do, it should be as simple as possible, so that the user can have a good mental-model of what is going on.
Hmm... I'm a bit confused that for string interpolation, you have to put double-quotes into the string yourself (
"{{my_string}}"), but for arrays and objects, you don't have to put[ ]and{ }around them.Of course, fixing this by removing the need to put
"around the string would break backwards-compatibility in a really bad way, and it would break otherwise needed functionality where you just want to plop a raw string into some body. (I sometimes need to send invalid JSON as part of my tests).The more I think about this: Trying to solve serialization for the user is really tricky. Whatever we do, it should be as simple as possible, so that the user can have a good mental-model of what is going on.
Yeah, I also thought about this and the first implementation was like this (Nothing must be quoted). But then I saw dw-0 and other wrapping strings with double quotes. In the end it's probably Anoops decision on how this should look like.