On APEX 5 RESTful services [1] I need to dynamically build a JSON object inside PL/SQL. Not sure if using htp.p is the best solution. In the first example below line 7 returns a proper JSON. All good. Now the second example does not. It seems htp.p only takes a string as input. Is there another way of doing this?
A static JSON:
returns {"status":"success"}
DECLARE
rvalue varchar2(200);
BEGIN
rvalue := adduser(:email, :password);
IF rvalue = 1 THEN
htp.p('{"status":"success"}');
END IF;
END;
A dynamic JSON:
returns {"status": l.employee.first_name} when {"status": "Bella"} is expected [2]
DECLARE
l_employee pdb3_participants%ROWTYPE;
BEGIN
SELECT *
INTO l\_employee
FROM pdb3\_participants
WHERE id = 17;
htp.print('{"status": l.employee.first_name}');
END;
[1]

[2]
