Skip to main content
change var to set
Source Link

In the Marketing Cloud Summer '23 release, there is a new function named BuildRowsetFromJson(1,2,3). It works very similar to BuildRowsetFromXml.

Parameter 1 - Source string

Parameter 2 - JSON Path string which specifies what to build the rowset from

Parameter 3 - If true, returns an empty set on error instead of throwing

%%[

var @json, @rowCount

set @json = ""
set @json = concat(@json, '{ "store": {')
set @json = concat(@json, '    "book": [')
set @json = concat(@json, '        { "category": "reference",')
set @json = concat(@json, '        "author": "Nigel Rees",')
set @json = concat(@json, '        "title": "Sayings of the Century",')
set @json = concat(@json, '        "price": 8.95')
set @json = concat(@json, '        },')
set @json = concat(@json, '        { "category": "fiction",')
set @json = concat(@json, '        "author": "Evelyn Waugh",')
set @json = concat(@json, '        "title": "Sword of Honour",')
set @json = concat(@json, '        "price": 12.99')
set @json = concat(@json, '        }')
set @json = concat(@json, '    ]')
set @json = concat(@json, '}}')

  set @books = BuildRowsetFromJSON(@json,"$.store[0].book[*]",1)
  set @rowCount = rowcount(@books)

  if @rowCount > 0 then

    for @i = 1 to @rowCount do

      varSET @title = Field(Row(books,@i),'title')

      ]%%

       <br><p>Title: %%=v(@title)=%%</p>

      %%[

    next @i

  else

   output(concat("<br>no books found"))

  endif

]%%

In the Marketing Cloud Summer '23 release, there is a new function named BuildRowsetFromJson(1,2,3). It works very similar to BuildRowsetFromXml.

Parameter 1 - Source string

Parameter 2 - JSON Path string which specifies what to build the rowset from

Parameter 3 - If true, returns an empty set on error instead of throwing

%%[

var @json, @rowCount

set @json = ""
set @json = concat(@json, '{ "store": {')
set @json = concat(@json, '    "book": [')
set @json = concat(@json, '        { "category": "reference",')
set @json = concat(@json, '        "author": "Nigel Rees",')
set @json = concat(@json, '        "title": "Sayings of the Century",')
set @json = concat(@json, '        "price": 8.95')
set @json = concat(@json, '        },')
set @json = concat(@json, '        { "category": "fiction",')
set @json = concat(@json, '        "author": "Evelyn Waugh",')
set @json = concat(@json, '        "title": "Sword of Honour",')
set @json = concat(@json, '        "price": 12.99')
set @json = concat(@json, '        }')
set @json = concat(@json, '    ]')
set @json = concat(@json, '}}')

  set @books = BuildRowsetFromJSON(@json,"$.store[0].book[*]",1)
  set @rowCount = rowcount(@books)

  if @rowCount > 0 then

    for @i = 1 to @rowCount do

      var @title = Field(Row(books,@i),'title')

      ]%%

       <br><p>Title: %%=v(@title)=%%</p>

      %%[

    next @i

  else

   output(concat("<br>no books found"))

  endif

]%%

In the Marketing Cloud Summer '23 release, there is a new function named BuildRowsetFromJson(1,2,3). It works very similar to BuildRowsetFromXml.

Parameter 1 - Source string

Parameter 2 - JSON Path string which specifies what to build the rowset from

Parameter 3 - If true, returns an empty set on error instead of throwing

%%[

var @json, @rowCount

set @json = ""
set @json = concat(@json, '{ "store": {')
set @json = concat(@json, '    "book": [')
set @json = concat(@json, '        { "category": "reference",')
set @json = concat(@json, '        "author": "Nigel Rees",')
set @json = concat(@json, '        "title": "Sayings of the Century",')
set @json = concat(@json, '        "price": 8.95')
set @json = concat(@json, '        },')
set @json = concat(@json, '        { "category": "fiction",')
set @json = concat(@json, '        "author": "Evelyn Waugh",')
set @json = concat(@json, '        "title": "Sword of Honour",')
set @json = concat(@json, '        "price": 12.99')
set @json = concat(@json, '        }')
set @json = concat(@json, '    ]')
set @json = concat(@json, '}}')

  set @books = BuildRowsetFromJSON(@json,"$.store[0].book[*]",1)
  set @rowCount = rowcount(@books)

  if @rowCount > 0 then

    for @i = 1 to @rowCount do

      SET @title = Field(Row(books,@i),'title')

      ]%%

       <br><p>Title: %%=v(@title)=%%</p>

      %%[

    next @i

  else

   output(concat("<br>no books found"))

  endif

]%%
Source Link

In the Marketing Cloud Summer '23 release, there is a new function named BuildRowsetFromJson(1,2,3). It works very similar to BuildRowsetFromXml.

Parameter 1 - Source string

Parameter 2 - JSON Path string which specifies what to build the rowset from

Parameter 3 - If true, returns an empty set on error instead of throwing

%%[

var @json, @rowCount

set @json = ""
set @json = concat(@json, '{ "store": {')
set @json = concat(@json, '    "book": [')
set @json = concat(@json, '        { "category": "reference",')
set @json = concat(@json, '        "author": "Nigel Rees",')
set @json = concat(@json, '        "title": "Sayings of the Century",')
set @json = concat(@json, '        "price": 8.95')
set @json = concat(@json, '        },')
set @json = concat(@json, '        { "category": "fiction",')
set @json = concat(@json, '        "author": "Evelyn Waugh",')
set @json = concat(@json, '        "title": "Sword of Honour",')
set @json = concat(@json, '        "price": 12.99')
set @json = concat(@json, '        }')
set @json = concat(@json, '    ]')
set @json = concat(@json, '}}')

  set @books = BuildRowsetFromJSON(@json,"$.store[0].book[*]",1)
  set @rowCount = rowcount(@books)

  if @rowCount > 0 then

    for @i = 1 to @rowCount do

      var @title = Field(Row(books,@i),'title')

      ]%%

       <br><p>Title: %%=v(@title)=%%</p>

      %%[

    next @i

  else

   output(concat("<br>no books found"))

  endif

]%%