Reads a JSON payload a model wrote, fixing the mistakes models commonly
make, as the reference SDKs' payload fixer (parse_and_fix) does.
iex> A2UIAgent.PayloadFixer.parse_and_fix(~s({"text": "Hi",}))
{:ok, [%{"text" => "Hi"}]}Curly quotes are made straight, raw control characters inside strings are accepted, and when the payload does not read, trailing commas before a closing bracket are dropped and it is read again. A single object comes back wrapped in a list.
The direct JSON parser reads blocks with the more forgiving
A2UIAgent.DirectJson.JsonReader; this fixer is for code that wants
the reference's exact rules.
Summary
Functions
Reads payload. Fails with a :parse error that says what is wrong,
with a hint for a backslash that is not escaped.
Functions
@spec parse_and_fix(String.t()) :: {:ok, [term()]} | {:error, A2UICore.Error.t()}
Reads payload. Fails with a :parse error that says what is wrong,
with a hint for a backslash that is not escaped.