quote

This page explains how to use the quote function in APL.

Use the quote function in APL to return a string literal representation of a given input value. This function wraps the value in double quotation marks and escapes any internal double quotes or special characters as needed. This is especially useful when you want to ensure that string values are safely embedded in dynamically constructed queries, logs, or debug output without being misinterpreted.

You can use quote to:

  • Safely format strings for output or reuse.
  • Prevent syntax errors when generating queries dynamically.
  • Inspect values that contain special or unexpected characters.

Use this function when you need to serialize a string value exactly as it would appear in an APL query.

Usage

Syntax

quote(value)

Parameters

NameTypeDescription
valuestringThe value to quote and escape

Returns

A string value representing the input enclosed in double quotes, with internal quotes and escape sequences handled appropriately.

Use case examples

In log analysis, you might want to safely quote URI strings for inclusion in alerts or dashboards.

Query

['sample-http-logs']
| where method == 'POST'
| summarize count() by quoted_uri = quote(uri)

Run in Playground

Output

quoted_uricount_
"/api/login"83
"/api/purchase"61
"/search?q%3Derror"12

This query quotes the URI paths in log entries, ensuring that any special characters are preserved in output.

In OpenTelemetry traces, quoting service.name values helps safely display or export the names in logs or dashboards where special characters could otherwise break formatting.

Query

['otel-demo-traces']
| summarize count() by quoted_service = quote(['service.name'])

Run in Playground

Output

quoted_servicecount_
"frontend"1041
"checkoutservice"853
"productcatalogservice"790

The query quotes service names for safe export or logging.

Other query languages