Working with a set of Json Objects, I use a javascript map function to list each field along with an array of its possible types. For example:
birthDate, [Date, String, String, String, String]
isMarried, [Boolean, Boolean, Boolean, Boolean, String]
name, [String, String, String, String, String]
Each field is linked to an array that includes all possible types represented as strings, including duplicates. I am using a reduce function to remove the duplicate types:
reduce = function(key, stuff){return Array.unique(stuff).toString()}
While this reduce function successfully removes duplicates for some types, it does not work for others.