Question: I'm trying to setup a form where some fields needs to be hidden depending on the user role. I'm doing this in my own module using hook\_form\_FORM\_ID\_alter. No problem with common text, email or link fields (e.g. $form['field\_companyname']['und'][0]['value']['#type']='hidden'). But for an image field or a multiple value file field the usual way won't work.

Anybody can give me a clue?

Answer: 
Use [GSON](http://code.google.com/p/google-gson/) library from google. It has a a lot of setting to read/create/parse json array and json objects. I didn't test it to find the solution, but I think it's very simple and full featured tool and can solve the problem.
There is also the method [names();](http://developer.android.com/reference/org/json/JSONObject.html#names%28%29)

> 
> Returns an array containing the string names in this object.
> 
> 
> 

Edit: returns names in undefined order. Suggestions: parse it on your own