Added toFlatJSON method.