Bonjour à tous.
j'ai une procédure qui permet de retourner une chaine au format JSON. et à l'intérieur de cette chaine je voudrais récupérer la valeur du token. comment faire ?
voici la procédure :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
procedure GetToken(  p_url  IN  CHAR,  p_username IN CHAR DEFAULT NULL,  p_password IN CHAR DEFAULT NULL) is
 
  http_request   UTL_HTTP.req;
  http_response  UTL_HTTP.resp;
  http_text           VARCHAR2(32767);
  content varchar2(4000):='{ "login":"'||p_username||'","password":"'||p_password||'"}';
 
BEGIN
  -- Make a HTTP request and get the response.
  http_request  := UTL_HTTP.begin_request(p_url, 'POST','HTTP/1.1');
 
  utl_http.set_header(http_request, 'user-agent', 'chrome/87.0'); 
  utl_http.set_header(http_request, 'content-type', 'application/json');
  utl_http.set_header(http_request, 'Content-Length', length(content));
 
 
utl_http.write_text(http_request, content);
 
http_response := utl_http.get_response(http_request);
 
 
  -- Loop through the response.
  BEGIN
    LOOP
      UTL_HTTP.read_text(http_response, http_text, 32766);
      DBMS_OUTPUT.put_line (http_text);
    END LOOP;
  EXCEPTION
    WHEN UTL_HTTP.end_of_body THEN
      UTL_HTTP.end_response(http_response);
  END;
EXCEPTION
  WHEN OTHERS THEN
    UTL_HTTP.end_response(http_response);
    RAISE;
 
END ;
et voici un exemple de la chaine qui est retournée:
{"etat":{"code":200,"message":"success","count":2},"reponse":{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MDY4MTg5MjIsImV4cCI6MTYwNjkwNTMyMiwianRpIjoiNWNKOGtGejNRM0hxc2xNbjFtbmVCOSJ9.sAj0TpjNmJo5iWj5L5FFnq8mQlT4-U_V5rpCyHedUD49NKb9c-o9idiAALSr8akOTro4Y7o6eAJZQw4hhQsysQ","message":"La mise à jour du Token a été faite"}}