serpapi / public-roadmap

Public Roadmap for SerpApi, LLC (https://serpapi.com)
50 stars 3 forks source link

[Playground] Double quotes not escaped in playground values #1879

Open dsojevic opened 2 weeks ago

dsojevic commented 2 weeks ago

In the Playground (and in the embedded playgrounds in the API documentation), double quotes are not escaped in the resulting values: image

The actual JSON returned from the API has these values correctly escaped, so this is a Playground-specific display issue: image

Diff of the specific example highlighted here:

{
  "question": "Is John Wick based on a true story?",
-  "snippet": "Jonathan \"John\" Wick is a fictional character created by American screenwriter Derek Kolstad and portrayed by Canadian actor Keanu Reeves. He is the titular protagonist of the neo-noir media franchise John Wick.",
+  "snippet": "Jonathan "John" Wick is a fictional character created by American screenwriter Derek Kolstad and portrayed by Canadian actor Keanu Reeves. He is the titular protagonist of the neo-noir media franchise John Wick.",
  "title": "John Wick (character) - Wikipedia",
  "link": "https://en.wikipedia.org/wiki/John_Wick_(character)#:~:text=Jonathan%20%22John%22%20Wick%20is%20a,noir%20media%20franchise%20John%20Wick.",
  "displayed_link": "https://en.wikipedia.org › wiki › John_Wick_(character)",
  "thumbnail": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTPApXbzTbASW5xFcx4G-Ib04KcI-yCnegpCwHb9nwJehyNhrVHKh2Oe7mqGg&s",
  "source_logo": "https://serpapi.com/searches/66ceec626a5dd3ba7e257bbb/images/bb64aafb86f0469528477cf5da02fd9d070fdc9f7d0d14051d3441e31d8b3a9a.png",
  "next_page_token": "...",
  "serpapi_link": "..."
}

Search Inspect | Playground

sonika-serpapi commented 2 weeks ago

@dsojevic Thank you for reporting this issue! Our team will look into it and get back on this.

sonika-serpapi commented 2 weeks ago

@tanys123 Do you have additional insight into this? I talked with @schaferyan about this, and we think this may be by design as we probably render escaped characters for readability, but wanted to confirm.

schaferyan commented 2 weeks ago

For further context, you can see the characters escaped correctly in the playground by enabling "Show raw JSON" in "Tools":

Screenshot 2024-08-29 at 10 09 23 AM
dsojevic commented 2 weeks ago

I talked with @schaferyan about this, and we think this may be by design as we probably render escaped characters for readability, but wanted to confirm.

The reason I initially came across this was that I was copying a fragment of the response to test with and it came back as unparseable JSON due to the unescaped quotes.

If the escape characters aren't displayed by design, I think that's fine. However, I'd strongly suggest keeping them in the HTML and hiding them as you would with screenreader-only text so that it still results in valid JSON if you copy + paste a section of the response from the playground (not in raw JSON mode).

Alternately, you could display the escape character and lowlight it so it's "out of the way" for readability, but still present for validity of the structure, eg. image

sonika-serpapi commented 2 weeks ago

@dsojevic Thank you for your suggestion! We will take it into consideration.