JSON Escaping and Encoding/JSON string containing JSON

Sometimes one field stores another JSON document as a string.

Section: Encoding pitfalls

JSON string containing JSON

json
json
{
  "payload": "{\"event\":\"signup\",\"ok\":true}"
}
Explanation

This is valid, but consumers must decode the outer JSON and then parse the inner string separately.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Encoding pitfalls
Prefer UTF-8 encoded JSON
UTF-8 is the de facto standard for JSON payloads.
OpenIn sheettextsame section
Decode embedded JSON with jq
Parse a JSON string field into structured data.
OpenIn sheetbashsame section
Encode structured data as a JSON string
Turn a value into a JSON-encoded string.
OpenIn sheetbashsame section
Escape a backslash
Represent a literal backslash inside a string.
OpenIn sheetjson2 tag match
Escape a forward slash if needed
Escaping `/` is optional in JSON.
OpenIn sheetjson2 tag match
Escape control characters
Use `\n`, `\r`, and `\t` for control characters.
OpenIn sheetjson2 tag match