Support raw string
Problem to solve
When using JSON body or multiline string, {{ is interpreted as a variable expansion by Hurl.
For instance, this JSON body:
{
"template": "{{#user~}}I want a response to the following query:{{query}}{{~/user}}"
}
Should be sent either with JSON unicode literal:
POST http://localhost:8000/api/v1/messages
{
"template": "\u007B\u007B#user~\u007D\u007DI want a response to the following query:\u007B\u007Bquery\u007D\u007D\u007B\u007B~/user\u007D\u007D"
}
or with Hurl unicode literal:
POST http://localhost:8000/api/v1/messages
```json
{
"template": "\u{7b}\u{7}#user~\u{7D}\u{7D} want a response to the following query:\u{7b}\u{7b}query\u{7d}\u{7d}\u{7d}\u{7d}~/user\u{7d}\u{7d}"
}
```
Proposal
Use "multiline string" with raw hint to disable all variable interpolation.
POST http://localhost:8000/api/v1/messages
```raw
{
"template": "{{#user~}}I want a response to the following query:{{query}}{{~/user}}"
}
```
What is the current solution to sending {{}} string literals in JSON payloads? I can't make it work...
Regarding the raw proposal, mixed request bodies where I want to evaluate variables but also use literals should be considered, so marking the whole body as either of the two might not be the best solution.
Hi @michelkaeser
Can you use JSON unicode literal ({ => \u007B, } => \u007D) ?
POST http://localhost:8000/api/v1/messages
{
"template": "\u007B\u007B#user~\u007D\u007DI want a response to the following query:\u007B\u007Bquery\u007D\u007D\u007B\u007B~/user\u007D\u007D"
}
As it's a valid JSON compliant string (independant of Hurl format), it should be OK
Related #2428
Hi @michelkaeser
Can you use JSON unicode literal (
{=>\u007B,}=>\u007D) ?POST http://localhost:8000/api/v1/messages { "template": "\u007B\u007B#user~\u007D\u007DI want a response to the following query:\u007B\u007Bquery\u007D\u007D\u007B\u007B~/user\u007D\u007D" }As it's a valid JSON compliant string (independant of Hurl format), it should be OK
JSON unicode literal worked successfully after all. Many thanks!