How to read a JSON with ORACLE

How can I make a query or function that allows me to obtain the description when sending the language en_US or es_LA

Currently what I have in the OFFER_DESC field is the text indicated below

SELECT OFFER_DESC FROM TAB_DESCRIPTION
{"en_US":"English text example","es_LA":"Ejemplo de texto en español"}

How can I send the language en_US or es_LA and get the value English text example or Ejemplo de texto en español

Upvotes: 1

Views: 121

Answers (1)

OldProgrammer
OldProgrammer

Reputation: 12179

Maybe this?

    with TAB_DESCRIPTION as(
    SELECT '{"en_US":"English text example","es_LA":"Ejemplo de texto en español"}'  OFFER_DESC FROM dual )
    select json_value( offer_desc, '$.en_US'),json_value( offer_desc, '$.es_LA') 
from tab_description

Upvotes: 1

Related Questions