Escaped strings in queries and in returned items
When constructing your queries, you must escape certain characters in your query strings. Similarly, when processing the items returned by your query, your web application must process any escape strings they may contain that represent things like hard returns or tabs.
Characters represented as escaped strings in JSON
| Character | Escaped string |
|---|---|
| Hard return | \n |
| Tab | \t |
| Double quote | \" |
| Backslash | \\ |
Escaping characters in your queries
When constructing a query, ensure that you replace all hard returns, tab characters, double quotes and backslashes are replaced with their escaped strings. This means doubly escaping in your GraphQL calls.
searchByField query. The location is \400 Example Site\Building Blocks\Modules\Core\Admin\. You would escape this path as follows in your searchByField call:
searchByField(indexName: "stagingudp-index", field:"location", value:"\\\\400 Example Site\\\\Building Blocks\\\\Modules\\\\Core\\\\Admin", strict:true, after: "Mg==", first: 10)
"publicationTitle": "400 Example Site", "location": "\\400 Example Site\\Building Blocks\\Modules\\Core\\Admin",
Processing escaped strings in your query responses
<p>example</p>
<p style="text-decoration: underline;">important!</p>
<p><strong>some bold statement</strong></p>
<p>A further example</p>
\n:
<p>example</p>\n<p style="text-decoration: underline;">important!</p>\n<p><strong>some bold statement</strong></p>\n<p>A further example</p>
Your code must now replace the \n instances with actual hard returns in order to recreate the original HTML.