Skip to content

Using 'Repetition' syntax in templated JSON #16

@mortifactor

Description

@mortifactor

Hi!

I'm trying to use webhook to send alerts to Telegram. So my body should look like this:

{
  "chat_id": "123456",
  "text": "alert content"
}

And I would like to send the value of Source.Results using repetition syntax as I've found in https://github.com/serilog/serilog-expressions?tab=readme-ov-file#repetition

{ {
  chat_id: '123456',
  text: {#each k, v in @p['Source']['Results']}{k} = {v}{#delimit},{#end}
} }

But the template above gives me error
System.ArgumentException: Syntax error (line 3, column 8): unexpected #.

At the same time if I use it like this

{ {
  chat_id: '123456',
  text: @p['Source']['Results']
} }

it is ok, but this gives me unformatted array value. And I would like to concat formatted array output like this:

text: concat(@p['Alert']['Title'], '\n', {#each k, v in @p['Source']['Results']}{k} = {v}{#delimit},{#end})

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions