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: 
The JSONObject documentation (link: <http://developer.android.com/reference/org/json/JSONObject.html>) has the following description for the `keys()` function:

> 
> public Iterator keys ()
> 
> 
> Since: API Level 1
> 
> 
> Returns an iterator of the String names in this object. The returned
>  iterator supports remove, which will remove the corresponding mapping
>  from this object. If this object is modified after the iterator is
>  returned, the iterator's behavior is undefined. **The order of the keys
>  is undefined**.
> 
> 
> 

So you may get the keys but the order is undefined. You may use any of the sorting algorithms if you want the keys in any particular order.

**EDIT**

Since you are unaware of the order of KEYS you are getting from the WS, after receiving the data you may show the details on screen in an ordered format . After building the `arraylist` `KEYS`, you may sort it alphabetically using the following:

```
Collections.sort(KEYS);  

```

This will order the `Strings` in the `KEYS` `arraylist` according to its *natural ordering* (which is *alphabetically*).
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