Variety expects keys to be well formed, not having any '.'s in them (mongo 2.4 allows dots in certain cases). Also mongo uses the psudo keys 'XX' and keys coresponding to the regex 'XX\d+XX.*' for use with arrays. You can change the string XX in these patterns to whatever you like if there is a conflict in your database using the `arrayEscape` parameter.
key='XX';//translate unnamed object key from {_parent_name_}.{_index_} to {_parent_name_}.XX
key=config.arrayEscape+key+config.arrayEscape;//translate unnamed object key from {_parent_name_}.{_index_} to {_parent_name_}.arrayEscape{_index_}arrayEscape.
result[parentKey+key]=value;
//it's an object, recurse...only if we haven't reached max depth