Write JSON structure to file