Skip to content

[pat-auto-suggest] properly accept json for prefill-json #1278

@ale-rt

Description

@ale-rt

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions