def get_as_type json_path, type, json=nil
      value = get json_path, json
      case type
        when 'numeric'
          valid = value.is_a? Numeric
        when 'array'
          valid = value.is_a? Array
        when 'string'
          valid = value.is_a? String
        when 'boolean'
          valid = !!value == value
        when 'numeric_string'
          valid = value.is_a?(Numeric) or value.is_a?(String)
        when 'object'
          valid = value.is_a? Hash
        else
          raise %/Invalid expected type '#{type}'/
      end

      unless valid
        raise %/Expect '#{json_path}' as a '#{type}' but was '#{value.class}'\n#{to_json_s}/
      end
      value
    end
def get_as_type json_path, type, json=nil
      value = get json_path, json
      case type
        when 'numeric'
          valid = value.is_a? Numeric
        when 'array'
          valid = value.is_a? Array
        when 'string'
          valid = value.is_a? String
        when 'boolean'
          valid = !!value == value
        when 'numeric_string'
          valid = value.is_a?(Numeric) or value.is_a?(String)
        when 'object'
          valid = value.is_a? Hash
        else
          raise %/Invalid expected type '#{type}'/
      end

      unless valid
        raise %/Expect '#{json_path}' as a '#{type}' but was '#{value.class}'\n#{to_json_s}/
      end
      value
    end
Retrieve value of the first JSON element with given JSON path as given type
 @param json_path [String] a valid JSON path expression
 @param type [String] required type, possible values are 'numeric', 'array', 'string', 'boolean', 'numeric_string'
 or 'object'
 @param json [String] optional JSON from which to apply JSON path, default to response body
 @return [Object] value of first retrieved JSON element in form of given type
 @raise [Exception] if JSON path is invalid or no matching JSON element found or matching element does not match
 required type