code: public String requestToJson(HppRequest hppRequest, boolean encoded ) {
  
  		LOGGER.info("Converting HppRequest to JSON.");
  
  		String json = null;
  
  		//generate defaults
  		LOGGER.debug("Generating defaults.");
  		hppRequest.generateDefaults(secret);
  
  		//validate request
  		LOGGER.debug("Validating request.");
  		ValidationUtils.validate(hppRequest);
  
  		//encode 
  		LOGGER.debug("Encoding object.");
  		try {
  			if(encoded){
  				hppRequest = hppRequest.encode(ENCODING_CHARSET);
  			}
  			
  		} catch (UnsupportedEncodingException ex) {
  			LOGGER.error("Exception encoding HPP request.", ex);
  			throw new RealexException("Exception encoding HPP request.", ex);
  		}
  
  		//convert to JSON
  		LOGGER.debug("Converting to JSON.");
  		json = JsonUtils.toJson(hppRequest);
  
  		return json;
  	}
docs: <p>
  Method produces JSON from <code>HppRequest</code> object.
  Carries out the following actions:
  <ul>
  <li>Validates inputs</li>
  <li>Generates defaults for security hash, order ID and time stamp (if required)</li>
  <li>Optional to Base64 encode inputs</li>
  <li>Serialises request object to JSON</li>
  </ul>
  </p>
  
  @param hppRequest
  @param encoded <code>true</code> if the JSON values should be encoded.
  @return String