Cleaning up null elements from JSON payload
Hello All,
I am just wondering if there is any inbuilt function or utility available in IRIS to clean up "null" elements from JSON e.g. I want to remove "null" elements from payload below before I do any processing with it.
{
recipients: [
{ "name":"Utsavi", "email":"utsavi@gmail.com"},
{ "name":"Utsavi 1", "email":"utsavi1@gmail.com"},
null, null
],
content:[null, {"title":"Test.pdf", "data":"ygwehfbnwfbhew"} ]
}
Thanks & Regards,
Utsavi
Product version: IRIS 2021.1
Hi guys,
Tagging you both for your expert advise :)
@Dmitry Maslennikov @Eduard Lebedyuk
Cheers,
Utsavi
I think this may help
And Testing metho
Will return this
Perfect ! Thanks very much Dmitry :)
Thanks Dmitry. This worked perfectly and fixed an issue we had with a vendor that wanted empty fields removed from messages sent to them. Much appreciated.
Just create a simple method like this:
gives you
Be careful with multiple %Remove, it moves the index. So, the next %Remove in a row, will remove the wrong item.
And even with %Remove will not reach subsequent items
OK, this is the correct(ed) version:
Thanks for the hint, I saw the problem right after answering.
Do we have a backwards-%GetNext(), i.e. an %GetPrevious()?
JSON is binary in a low level, so, the same as for $listbuild, I think only one way to go, and it is from begin to end
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue