Runtime verified Differs from official docs Test scripts included

Dynamically accesses an object property or array element by a variable key.

Syntax

{{lookup object key}}

Returns any.

Parameters

Name Type Required Description
object any Yes Object or array to read from.
key any Yes Property name or array index to read.

Example

Tested in Marketing Cloud Next emails on 2026-11-22 and 2026-11-25:

  • {{lookup (hash k="v") "k"}} renders v, as documented.
  • {{lookup (hash k="v") "missing"}} renders {k=v}. The documented result is an empty string.
  • With a list of two rows built in AMPscript (%%[ SET @rows = BuildRowsetFromJSON('[{"name":"Bob","age":27},{"name":"Ann","age":21}]', '$[*]', 1) ]%%), {{lookup (lookup rows 0) "name"}} renders Bob.
Show Next test script
<!-- Marketing Cloud Next test script for the lookup helper. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[v] got=[{{lookup (hash k="v") "k"}}]</p>
<p>c2 expect=[{k=v}] got=[{{lookup (hash k="v") "missing"}}]</p>
<p>c3 expect=[Bob] got=[%%[ SET @rows = BuildRowsetFromJSON('[{"name":"Bob","age":27},{"name":"Ann","age":21}]', '$[*]', 1) ]%%{{lookup (lookup rows 0) "name"}}]</p>

Differs from official docs

  • The reference says that a key which does not exist gives undefined, which renders as an empty string. In Marketing Cloud Next (tested 2026-11-22): {{lookup (hash k="v") "missing"}} rendered {k=v}, the whole object, instead of an empty string. An existing key, {{lookup (hash k="v") "k"}}, rendered v. Details

Marketing Cloud Next

See also