okay, thanks, got it somehow:
<@ snippet tree @>
<# Only create new list in case the current context has children #>
[
<@~ foreach in pagelist @>
<@~ comma ~@>
{
"url": "@{ :origUrl }",
"title": "@{ title }",
"date": "@{ date }",
"active": <@ if @{ :current } @>true<@ else @>false<@ end @>,
"course": <@ if @{ :kurs } @>true<@ else @>false<@ end @>,
"has_childs": <@ if @{ :pagelistCount } > '0' @>true<@ else @>false<@ end @>,
"children": <@ if @{ :pagelistCount } > '0' @><@ tree @><@ else @>[]<@ end @>
}
<@~ end ~@>
]
<@~ end ~@>
<@ snippet navi ~@>
<@~ newPagelist { type: 'children', excludeHidden: true, excludeCurrent: false} ~@>
{
"url": "@{ :origUrl }",
"title": "@{ title }",
"date": "@{ date }",
"active": <@ if @{ :current } @>true<@ else @>false<@ end @>,
"course": <@ if @{ :kurs } @>true<@ else @>false<@ end @>,
"has_childs": <@ if @{ :pagelistCount } > '0' @>true<@ else @>false<@ end @>,
"children": <@ if @{ :pagelistCount } > '0' @>
<@~ with "/" @>
<# Call recursive tree snippet #>
<@~ tree @>
<@~ end @>
<@ else @>[]<@ end @>
}
<@~ end ~@>