-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add support for quotation marks in JSON operators #203
Comments
Interesting idea, but it is not as easy as it seems as you probably want the following works too:
for example, so the JSON parser has to be reentrant as when we get "$^" we are in the lexer go-testdeep/internal/json/lex.go Line 459 in 0da89a9
|
Ah, I see, seems relatively complicated. I might try implementing it, whenever I have free time. |
Hi @r6q, if you still need this feature could you review #217 please? I also added the possibility to have raw string in JSON, useful to avoid escaping double-quotes for strings-in-strings: // with raw string:
td.Cmp(t, got, td.JSON(`{"name": "$^Re(r<^Bob \\w+$>)"}`))
// without raw string:
td.Cmp(t, got, td.JSON(`{"name": "$^Re(\"^Bob \\\\w+$>\""}`)) Until I write the documentation, all raw strings cases are listed here. |
- introduction of raw strings; - literal \n, \r & \t accepted in strings; - $^Operator(params...) is possible; - "$^Operator(params...)" is possible; - Operator (without parenthesis) is possible; - operator shortcuts reimplemented to not be handled specifically. Closes #203. Signed-off-by: Maxime Soulé <[email protected]>
- introduction of raw strings; - literal \n, \r & \t accepted in strings; - $^Operator(params...) is possible; - "$^Operator(params...)" is possible; - Operator (without parenthesis) is possible; - operator shortcuts reimplemented to not be handled specifically. Closes #203. Signed-off-by: Maxime Soulé <[email protected]>
- introduction of raw strings; - literal \n, \r & \t accepted in strings; - $^Operator(params...) is possible; - "$^Operator(params...)" is possible; - Operator (without parenthesis) is possible; - operator shortcuts reimplemented to not be handled specifically. Closes #203. Signed-off-by: Maxime Soulé <[email protected]>
Problem:
We use different operators in JSONs which are then used for comparison. If we add regular operators to json string, e.g.
Len
,HasPrefix
, etc, the JSON becomes invalid and formatters, validators cannot parse the string.Proposal:
Add support for quotation marks for operators in JSON strings, similarly to currently it is being used for shortcut operators
"$^NotEmpty"
. Ideally it could look similar"$^Len(10)"
The text was updated successfully, but these errors were encountered: