Escapar cadena JSON
json-string-escapeEscapa texto como literal de cadena JSON. Cuándo: hay que convertir bytes o texto a esta codificación, o desde ella, con exactitud y sin adivinar. No para: interpretar el cuerpo de un literal de cadena JSON y devolver el texto (json-string-unescape). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.
EN: Escapes text as the body of a JSON string literal (quotes, backslashes, control characters), with or without surrounding quotes. When: bytes or text have to be converted to or from this encoding exactly, without guessing. Not for: parsing the body of a JSON string literal (json-string-unescape). Side effects: none (read-only, no network access, no stored state). Deterministic: the same input gives the same output. Limits: JSON input up to 64 KB, 1 s per call, result up to 1 MB.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text (string; required). | |
| quotes | No | Include surrounding quotes (boolean; optional; default false). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| escaped | No |