code: public String resource_to_string(base_resource resrc, String id, options option,Boolean warning, String onerror) 
  	{
  		String result = "{ ";
  			if (option != null || (warning!=null && warning==true) || (!onerror.equals(""))) { 
  				result = result + "\"params\":{";
  				if(option != null)
  				{
  					if (option.get_action() != null) {
  						result = result + "\"action\":\"" + option.get_action() + "\",";
  					}					
  				}
  				if(warning != null && warning==true)
  				{
  					result = result + "\"warning\":\"yes\",";
  				}
  				if((!onerror.equals("")))
  				{			
  					result = result +"\"onerror\":\"" + onerror +"\"";			
  				}		
  				result  = result + "},";
  			}
  		
  		if (id != null)
  			result = result + "\"sessionid\":\"" + id + "\",";
  		
  		result = result + "\"" + resrc.get_object_type() + "\":" + this.resource_to_string(resrc) + "}";
  		return result;
  	}
docs: Converts netscaler resource to Json string.
  @param resrc nitro resource.
  @param id sessionId.
  @param option options class object.
  @return returns a String