JSON array with objects implode

Hello,

I have got a JSON document like

{
      author : [
          { given : "a", family : "b" }, { given : "c", family : "d" }
      ]
}

and I try to crete within my template a coma delimited list, so I do

{{ delimit ( apply $item.author ( print “.given” ", " “.family” ) “.” ) ", " }}

but this does not work, so I would like to get: a b, c d
How can I get a correct delimited string list from my objects?

Thanks

Phil

I suggest you break it up into smaller parts and read the documentation carefully. Not sure what you expect from the print func, for starters.

I try this, but I’m failing on the print command. I try to do it with

{{ $authorlist := "  " }}
{{ range $item := $json.author }}
    {{ $authorlist := (print $authorlist $item.given " " $item.family ", ") }}
{{ end }}
<em>{{ slice $authorlist 0 -2 }}</em>

At the em command the variable $authorlist is empty, exactly it has the value before the range call. If I do the output within the range I get the result, but I need the full concatinated list of all elements within the JSON list.

Thx

Phil

I just try it with

{{ range $publication.author }}
     <em>{{ print .given " " .family ", " }}</em>
{{ end }}

This works, but I get a trailing ; at the end (and I would like to remove it), but on

{{ apply $publication.author (print .given " " .family ", ") "." }}

I get the error at <apply $publication.a...>: error calling apply: can't find function <nil> <nil