XLAT Question

Alan DeKok alan.dekok at inkbridge.io
Tue Apr 14 12:27:42 UTC 2026


On Apr 13, 2026, at 4:59 PM, g4-lisz at tonarchiv.ch wrote:
> I read about the default / alternation syntax for string expansion, like %{%{Foo}:-bar}.
> 
> But what I needed is this: 
>   if (foo != '' ) ? '[ %{foo} ]' : 'null'.
> 
> This is for a JSON request string in a REST module configuration. The request property in question must be a JSON array (  [ .. ] ) or 'null'.
> 
> I could use Unlang IF and declare the complete JSON request in different versions depending on foo. But I would prefer to do this with expansion inside the JSON string definition, if possible.

  You'll have to use 'if'.  There is a mods-available/json, and you can do:

	%{json_encode:&foo}

  Except that if "foo" doesn't exist, it returns an empty json object: "{}"

  Alan DeKok

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20260414/08487dc9/attachment.sig>


More information about the Freeradius-Users mailing list