Reputation: 200
I'm receiving an ajax call with the next data:
[['Berlin'],['Berlin Wannsee'],['Berlin Hauptbahnhof']]
I know that, to be rendered with the autocomplete function of jquery it has to be in the correct json format, but this is what I have. There are any way to could use this directly?
I read something about _renderItem, but I don't know if this is what I need.
Upvotes: 1
Views: 50
Reputation: 366
I am afraid you will need to tranform it to a json compatible format.
Get rid of the first and last bracket Split the chain by the comma character Remove the apostrophees and brackets in the resulting array and you will have a clean array with the values you need. At this point you can loop through the array transforming to json manually or use a parser that will format it in a more automatic way.
Upvotes: 1