Mask an object's properties with an example object
Snippet
Universal
Advanced
Snippets are pieces of workflows. You can copy and paste them directly into any Tray workflow.
New to snippets? Watch this video
For more details please see our Snippet Documentation
About this SnippetCopy
Copy
This snippet allows you to apply a mask, or filter, to an object using an example object.
So if you have the object:
1{2person: {3name: "john doe",4email: "john@doe.com",5phone: "555-555-5555",6social: "555-55-5555",7kids: ["sally","michelle"]8}9}
But you only want to return their name and email, you provide the script with a filter object like:
1{2person: {3name: true,4email: true5}6}
And it will return:
1{2person: {3name: "john doe",4email: "john@doe.com"5}6}
The snippet includes an additional "demo" script that returns a sample set of data that you can use to test how it works. You'll only need the 2nd script in the snippet to perform the actual object filter/mask.
See it in actionCopy
Copy