Re: XLAT Question
Alan DeKok via Freeradius-Users <[email protected]> Tue, 14 Apr 2026 08:27:42 -0400
| Newsgroups | gmane.comp.freeradius.user |
|---|---|
| Message-ID | <[email protected]> |
--===============1991233752913114321== Content-Type: multipart/signed; boundary="Apple-Mail=_88E820BA-794F-4134-8E1F-99A4971F6F46"; protocol="application/pgp-signature"; micalg=pgp-sha256 --Apple-Mail=_88E820BA-794F-4134-8E1F-99A4971F6F46 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On Apr 13, 2026, at 4:59=E2=80=AFPM, [email protected] wrote: > I read about the default / alternation syntax for string expansion, = like %{%{Foo}:-bar}. >=20 > But what I needed is this:=20 > if (foo !=3D '' ) ? '[ %{foo} ]' : 'null'. >=20 > This is for a JSON request string in a REST module configuration. The = request property in question must be a JSON array ( [ .. ] ) or 'null'. >=20 > 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 --Apple-Mail=_88E820BA-794F-4134-8E1F-99A4971F6F46 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEIUl02elqcIsf1zM0v3SJ0h7dTTMFAmneMr4ACgkQv3SJ0h7d TTPxJQ//WZwmOCm9fNjAnSrxkCy0e8yuttJ/uKyIjrzARmZGbf9fnTUrKVaFm0jy nGDbHl+oAidLNYZjaLWmqEbRL0IeC6mrU/9KMWoSbGfWCrVTBj9DrcT/2czbKdgH kbau7L1fxpL3Dg4wTKcE7+ZlO0c3rApYvvruOr7NLjeJQI72nElBhyzb2lJrrkro 4bdFqLm+cmxEWgT2AWV4e6oey4aTXpDxJ8bVnPpdwTY/+qpAFm6zeSI2b0ZJRoUz 2YP/3DsyIsSeEsH2QYxL1LroHzKmhnsnh1tRK9aBEKCEmBRdKcWXMNSA2hVQCH9I gPouCr8ZAfCkf3WlhJhW6BptlQqz/s6ICoo2DjnzYKY3CXMVDk+GWQu529W5t/+n 5qnrEouO4pH2ybsqEDDNyDQEedAsVXQfrMdtMm5rpivo8X5vwnsZsRe4iqLxbL1p oKMDcIzuASg7SJAMasV4T3crSg1pOPOwt/pZfpmSrWQF7oeVPr3MJqARyABQbxK8 oxxHW8SJyUG9bED6IAxKoSYf4tb76VDxBUIu6xRM8W84/eLZP+dW2U0NKYq8E2R6 XatBukX7mOlyDqvlCRSPKMtC9jzUpRCusRXzBP8XZ4hH2p9gTxhqcig+G92JvYrd cmS0zea4jUPgEe/rAexuTqKbb2p95IlPNkZ6sORHSsiNoFoafLc= =eAnh -----END PGP SIGNATURE----- --Apple-Mail=_88E820BA-794F-4134-8E1F-99A4971F6F46-- --===============1991233752913114321== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html --===============1991233752913114321==--