I am trying to parse a json array and its objects to further make use of them in my mysql procedure.
But while reading the values it shows null. _list will contain
[{"floor_id":"5","length":"40"},{"floor_id":"6","length":"61"}]
Code:
CREATE DEFINER=`admin`@`%` PROCEDURE `manage_room`(IN _id INT,
IN _list JSON,
INOUT v_message varchar(1000),
INOUT v_code int
)
BEGIN
declare _floor_number int ;
declare floor_list_length int;
set floor_list_length =3;
iterator:
LOOP
IF floor_list_length = 0 OR floor_list_length IS NULL THEN
LEAVE iterator;
END IF;
select JSON_EXTRACT(_rooms_list,CONCAT('$._list[', `floor_list_length`, '].floor_id')) as f ;
select JSON_EXTRACT(_rooms_list,CONCAT('$._list[', `floor_list_length`, '].length')) as l ;
insert into temp(val,txt) values (f,l);
end loop;
end
Can someone correct me what mistake i am doing?