1. A method comprising using at least one hardware processor for: receiving input from a user with respect to masking of a data element in one or more documents of a java script object notation (JSON) type, said one or more documents each comprise a hierarchy of at least two levels identified by name-value pairs, wherein the input comprises: (i) an identifier of the data element, and (ii) one or more constraints for masking the data element based on the hierarchy of the one or more documents of the JSON-type, said one or more constraints define the masking with respect to a level of the at least two levels: and generating a masking rule for the one or more documents of the JSON-type based on the input, wherein the masking role is generated automatically upon completion of the masking rule being defined by the input; wherein the generating of the masking rule comprises generating a script; and the enforcing of the masking rule on the document comprises executing the script on the document.