Group_permissions using api in python

ok so I think I am a step closer…

first off -

 permissions: {admins: 1, staff: 2} 

The problem though is the above is cause this error:

NoMethodError (undefined method `each' for "stafff":String) /var/www/discourse/app/controllers       /categories_controller.rb:223:in `category_params'

Here’s the rub though… source code in discourse does the folowing:

        if p = params[:permissions]
          p.each do |k,v|
          p[k] = v.to_i
       end

The probelm here is p is not being seen as a hash in the controller.. I tried converting the permissions value to a json string hoping it would be prased by the api - so I did this:

permissions: json.dumps({"admins": 2, 'stafff': 3})

but no dice - just got this error:

NoMethodError (undefined method `each' for "{\"admins\": 2, \"stafff\": 3}":String)
/var/www/discourse/app/controllers/categories_controller.rb:223:in `category_params'

Can anyone see anything wierd or missing?