I have some code that does that I use to fill data-pat-autosuggest:
options = {"prefill-json": [{"id: "john-snow", "text": "John Snow"]}
return json.dumps(options)
I had to change it like this:
options = {"prefill-json": json.dumps([{"id: "john-snow", "text": "John Snow"])}
return json.dumps(options)
otherwise I got the error:
SyntaxError: non-JSON data given to pat-autosuggest
The reason for the need for this change is that this line:
|
const data = JSON.parse(this.options.prefillJson); |
Tries to parse in to a Json something which is already an array.
I think that it would be convenient to check if prefillJson is a string before trying to apply JSON.parse.