Added json encoding to model