Hi, I’m trying to test my solution and when I paste part of my developed code:
-- Schema: CREATE TABLE "rest-api" ("database" TEXT, "payload" TEXT, "url" TEXT, "result" TEXT);
-- Task: update the rest-api table and set the result based on the database, payload and url fields.
UPDATE "rest-api" as ra
SET result = (
CASE ifnull(json_type(ra.payload, '$.users'), 'null')
WHEN 'null' THEN
ra.database
WHEN 'array' THEN
(
SELECT json_set('{}', '$.users', json_array(db.value))
FROM json_each(ra.database, '$.users') as db
JOIN json_each(ra.payload, '$.users') as req
ON json_extract(db.value, '$.name')=req.value
)
ELSE 'unexpected'
END
)
WHERE ra.url = '/users';
But I received an error:
An error occurred
We received the following error when we ran your code:
Runtime error near line 14: malformed JSON
Which looked strange for me, and I tried to “Run tests” copy and pasting one of the solutions, and got the same error… Is the env bugged?