made toJSON recursive
1.7.0