USON :: Universal types included JSON.
- boolean
- number
- string
- array
- Date
- function
- prototype
USON는 UPPERCASE-CORE를 기반으로 만들어졌습니다.
npm install -s uson.js
require('uson.js');
<script src="UPPERCASE-CORE/BROWSER.js"></script>
<script src="USON.js"></script>
<script>
'use strict';
RUN(() => {
INIT_OBJECTS();
let data = {
msg : 'test',
date : new Date(),
func : () => {
console.log('ok!');
}
};
// where are date and func?
console.log(JSON.parse(JSON.stringify(data)));
// work correct.
console.log(USON.parse(USON.stringify(data)));
// ok!
USON.parse(USON.stringify(data)).func();
let Person = function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
};
Person.prototype.getName = function() {
return this.firstName + ' ' + this.lastName;
};
let originData = {
Person : Person,
person : new Person('Young Jae', 'Sim')
};
let newData = USON.parse(USON.stringify(originData));
console.log(new newData.Person('Young Jae', 'Sim').getName());
console.log(newData.person.getName());
});
</script>