Skip to content
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

Support raw string #1733

Open
jcamiel opened this issue Jul 6, 2023 · 4 comments
Open

Support raw string #1733

jcamiel opened this issue Jul 6, 2023 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Jul 6, 2023

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}}"
}
```
@jcamiel jcamiel added the enhancement New feature or request label Jul 6, 2023
@jcamiel jcamiel added this to the 4.3.0 milestone Feb 13, 2024
@jcamiel jcamiel added good first issue Good for newcomers and removed good first issue Good for newcomers labels Feb 15, 2024
@michelkaeser
Copy link

michelkaeser commented Apr 8, 2024

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.

@jcamiel
Copy link
Collaborator Author

jcamiel commented Apr 8, 2024

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

@jcamiel
Copy link
Collaborator Author

jcamiel commented Apr 8, 2024

Related #2428

@michelkaeser
Copy link

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!

@jcamiel jcamiel modified the milestones: 4.3.0, 5.0.0 Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants