It won't work with your JSON. But do you actually mean JSON? Or do you mean a Javascript array of objects? (Which you previously loaded from your server with Ajax and then parsed?)
Since you didn't supply any code (using jsFiddle is best) we have to guess!
I don't know exactly what you mean by "I can create the json array". Do you mean on your server? Or in your Javascript code? Again, you leave us guessing.
But why are you returning a JSON object with stuff that isn't needed? Is it because you have an existing server endpoint you want to repurpose? Or will you use the additional fields for something else?
See the various options you have for the source parameter:
It is common to confuse JSON representations (which are a textual encoding of variables/arrays/objects used to communicate across a network) with native variables/arrays/objects in some computer language (like Javascript).
Again, guessing!
If you use Ajax to retrieve a JSON representation of an array of objects from your server, parse it, and then extract a simple (native Javascript) array from the lastname values.
You can use map.
- var choices = myParsedArrayOfObjects.map(function(a) {
- return a.lastname;
- });
Then, supply choices as source.