Convert DOM tree to JSON structure.