some refactorings in ActiveModel json serialization