Often, APIs return JSON payloads wrapped as strings inside webhook inputs or text parameters. To map specific values downstream, you must convert these string elements back into accessible JavaScript objects.
Parsing JSON Strings
In n8n expressions, you can run inline JavaScript. Use JSON.parse() directly inside the double curly braces:
{{ JSON.parse($json.myStringKey).targetValue }}
Iterating Arrays and Safe Fallbacks
If there is a chance the key doesn't contain valid JSON, wrapping it directly can crash the execution. You can use a conditional ternary operator to handle fallbacks safely:
{{ $json.myStringKey ? JSON.parse($json.myStringKey).name : 'Guest' }}
Using these inline expression techniques saves you from having to place a separate Code node before every simple data mapping operation, keeping your canvas layout cleaner.