toJSON converts any DATASET data type instance into a JSON text instance.
Result Type
toJSON returns a JSON-encoded Avro or CSV value. The character set of the resulting JSON object is always UNICODE.
CSV values can contain multiple records, so the JSON value is an array of objects where each object contains the fields in a CSV record. For empty fields, the value equals the JSON null value. The resulting JSON object is in the same character set as the CSV value.
If there is no header record or schema with field names, default CSV field names generate. For defined field names with a record containing more than fields, default field names generate for the extra fields in the record. For example, if three field names are defined and a record contains four fields, the fourth field is named csv_fld4.