Fix JSON serialization with dynamic attributes

Closes #71