JSON JavaScript Object Notation
stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
const rabbit = {
name: 'tori',
size: null,
birthDate: new Date(),
symbol: Symbol('id'),
jump() { console.log(`${this.name} can jump!`);}
};
json = JSON.stringify(rabbit);
json = JSON.stringify(rabbit, ['name','size']);
json = JSON.stringify(rabbit, (key, value) => {
return key === 'name' ? 'John': value;
})
Symbol 같이 JS에만 있는 데이터나 함수는 전달되지 않는다.
parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
obj = JSON.parse(json)
obj = JSON.parse(json, (key, value) => {
return key === 'birthDate' ? new Date(value) : value
})
https://youtu.be/FN_D4Ihs3LE
http://www.jsondiff.com/
https://jsonbeautifier.org/
https://jsonparser.org/
https://tools.learningcontainer.com/json-validator/