Nullable Objects inside JSON

Hello there, I have an issue with rows where I add invoices and items that represent the items in JSON, but I'm sending 5 objects items at payload, and sometimes not all 5 objects are filled with data. Some might be nullable, and I don't want to send to the server the nullable objects. Thanks

Are you means when the properties is null, not add it to object which would send to the server, right?

I also found this and use it in retool days before.
Here is some answer

I'm not using JS is plain JSON as you can see I want just to send to server the objects that are filled

Maybe you need to use JS to filter the objects before send it to server. You can define JS function and pass data to it to filter it.
What I mean before is you can use inline JS in JSON. but it seem if all the properties of object is null, it still return a empty(without properties)object {}

Do I need to create another file with js function and what function to write and how to replace the data of payload with filtered one

You can write some function here and use it your query

If your want to define a global Function which would be access from all of your apps here is docs
Preload custom JavaScript in apps | Retool Docs.

json is not accepting the function


I write a demo for your reference, hope this can help.
Here is app json you can import to check detail.
test (1).json (10.5 KB)

1 Like

Thanks for this thorough response, @AnsonHwang! :white_check_mark:

The Object option (instead of key pairs) could also be helpful since you can put Javascript in that section to filter out null data