double quotation (repost from users mailing list)

30 views
Skip to first unread message

ramas...@gmail.com

unread,
Jun 2, 2016, 6:12:29 AM6/2/16
to Lettuce Developers
Hey Guys,
I have a test scenario like this

When I do POST request to /my/api/url
Then json response should match the following
"""
{
    "age": 29,
    "name": "test"
}
"""

However due to the decision of giving initial and trailing double quotation a special meaning, the string above becomes

{
age": 29,
name": "test
}

And there doesn't seem to be any straight forward solution to overcome this.
Would it be possible to add some settings flag to treat string between """ as it is?
I am a developer and totally willing to write a fix once package maintainers agree on it

Andrew Hughes

unread,
Sep 25, 2019, 10:00:25 PM9/25/19
to Lettuce Developers
I have the same issue. 

I my scenario, I expect non-developers to be able to copy/paste JSON out of chrome dev tools into scenario/steps. This expectation is flawed, as it's asking far too much of the user to expect them to be able to prefix an addition double quote to a line of text, if that line of text starts with a double quote.

I would like to just have...

And the following JSON can be parsed
"""
{
    "Hello" : "World"
}
"""

However, (as you point out, and for me to be verbose in my explanation) the first double quote before "Hello" is removed, and resulting in Hello" which is not valid JSON.

The only way I can get this to work is to add a double quote to the start of each line, or at the very least, just the ones that start with a double quote... so the following would work..

And the following JSON can be parsed 
"""
"{
"    "Hello" : "World"
"}
"""

or

And the following JSON can be parsed 
"""
{
    ""Hello" : "World"
}
"""

But given that our JSON is often up to ~100 lines long, it's not feasible (or efficient) to expect someone without basic DEV skills to craft the text/JSON around the double quote limitation. 

Can I suggest an additional parser/convention be considered?  
Reply all
Reply to author
Forward
0 new messages