jQuery

jquery JSON - stringify/

단순대왕 2014. 8. 29. 15:47

JSON.stringify()

The JSON.stringify() method converts a value to JSON, 

optionally replacing values if a replacer function is specified, 

or optionally including only the specified properties if a replacer array is specified.

alert(JSON.stringify({

제품명: '요구르트 드링크',

내용량: '30ml',

영양성분: {

열량: '100kcal',

탄수화물: '14g',

당류: '10g'

}

}));

[출력]

{{제품명: '요구르트 드링크',내용량: '30ml',영양성분: {열량: '100kcal',탄수화물: '14g',당류: '10g'}}}

alert(JSON.stringify({

... ... ...

}

}, null, 2));

[출력] 

{{

제품명: '요구르트 드링크',

내용량: '30ml',

영양성분: {

열량: '100kcal',

탄수화물: '14g',

당류: '10g'

}

}}