Issues with REST API SQLite

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?

The fact that you also get errors if you run code from other functioning solutions is strange.

Are you using a more recent version of SQLite than our test-runner? We use 3.37, which matches the latest Ubuntu LTS version.

Hi vaeng, thanks for answering, after more testing, I discover that if the result column is not in json format, it errors :frowning: so I need to fill all results rows before testing my solution