Move json serializer to library.
Add 'as' method