code: def get_m2m_value(session, request, obj):
      
      params = {}
      ''' m2m_request:
  
          {u'company[]': [u'["id", 1]'],
           u'professions[]': [u'["id", 2]', u'["id", 3]']}
      '''
      m2m_request = {k: v for k, v in list(request.items()) if k.endswith('[]')}
      for k, v in list(m2m_request.items()):
          key = k[:-2]
          relation = getattr(obj.__class__, key, False)
          if not relation:
              relation = getattr(obj, key, False)
          if not relation:
              continue  # pragma: no cover
          value = get_m2m_objs(session, relation, v)
          if value is None:
              continue
  
          if relation.property.uselist is False:
              if value:
                  value = value[0]
              else:
                  value = None
          params[key] = value
      return params
docs: Set m2m value for model obj from request params like "group[]"
  
          :Parameters:
  
              - `session`: SQLAlchemy DBSession
              - `request`: request as dict
              - `obj`: model instance