impl and tested factory encode/decode for internal protocol (JSONProtocol)