jsGrid to json 변환

javascript 2021. 6. 2. 17:03

function headerValues(){
return $( '#jsGrid' ).data( 'JSGrid' )
.fields
.filter( function( d ){
return d.name != '';
})
.map( function( d ){
return d.name
})
}

function dataObjects(){
return $( '#jsGrid' ).data( 'JSGrid' ).data
}

function createJSONForSingle( object ){
var hash = {};

headerValues().map( function( key ){
hash[ key ] = object[ key ]
});

return hash;
}

function createJSON(){
objects = dataObjects().map( function( o ){
return createJSONForSingle( o )
});

return JSON.stringify( objects, null, 2 );
}

 

https://gist.github.com/georgeu2000/29b4d17168708208266e44ff5c197f4f

반응형
Posted by 질주하는구
,