function json2csv( arr ) {
	var headers;
	var out;
	var tmp;
	var N;
	var M;
	var o;
	var v;
	var i;
	var j;

	out = '';
	if ( arr.length === 0 ) {
		return out;
	}
	headers = objectKeys( arr[ 0 ] );
	N = headers.length;
	for ( i = 0; i < N; i++ ) {
		out += headers[ i ];
		if ( i < N-1 ) {
			out += ',';
		}
	}
	out += '\r\n';

	M = arr.length;
	for ( i = 0; i < M; i++ ) {
		o = arr[ i ];
		tmp = '';
		for ( j = 0; j < N; j++ ) {
			v = o[ headers[ j ] ];
			v = replace( v, ',', '\\,' );
			v = replace( v, '"', '""' );
			tmp += '"' + v + '"';
			if ( j < N-1 ) {
				tmp += ',';
			}
		}
		out += tmp + '\r\n';
	}
	return out;
}
/**
* Converts a JSON array to a CSV string.
*
* @private
* @param {Array<Object>} arr - JSON array
* @returns {string} CSV string
*/
Converts a JSON array to a CSV string.
Converts a JSON array to a CSV string .
function json2csv( arr ) {
	var headers;
	var out;
	var tmp;
	var N;
	var M;
	var o;
	var v;
	var i;
	var j;
	out = '';
	if ( arr.length === 0 ) {
		return out;
	}
	headers = objectKeys( arr[ 0 ] );
	N = headers.length;
	for ( i = 0; i < N; i++ ) {
		out += headers[ i ];
		if ( i < N-1 ) {
			out += ',';
		}
	}
	out += '\r\n';
	M = arr.length;
	for ( i = 0; i < M; i++ ) {
		o = arr[ i ];
		tmp = '';
		for ( j = 0; j < N; j++ ) {
			v = o[ headers[ j ] ];
			v = replace( v, ',', '\\,' );
			v = replace( v, '"', '""' );
			tmp += '"' + v + '"';
			if ( j < N-1 ) {
				tmp += ',';
			}
		}
		out += tmp + '\r\n';
	}
	return out;
}
function json2csv ( arr ) { var headers ; var out ; var tmp ; var N ; var M ; var o ; var v ; var i ; var j ; out = '' ; if ( arr . length === 0 ) { return out ; } headers = objectKeys ( arr [ 0 ] ) ; N = headers . length ; for ( i = 0 ; i < N ; i ++ ) { out += headers [ i ] ; if ( i < N - 1 ) { out += ',' ; } } out += '\r\n' ; M = arr . length ; for ( i = 0 ; i < M ; i ++ ) { o = arr [ i ] ; tmp = '' ; for ( j = 0 ; j < N ; j ++ ) { v = o [ headers [ j ] ] ; v = replace ( v , ',' , '\\,' ) ; v = replace ( v , '"' , '""' ) ; tmp += '"' + v + '"' ; if ( j < N - 1 ) { tmp += ',' ; } } out += tmp + '\r\n' ; } return out ; }
Converts a JSON array to a CSV string.
Converts a JSON array to a CSV string .