Search code examples
jsonbooleanoracle-apex

Insert Boolean into JSON Payload in Oracle Apex


I'm using oracle apex 22.2.0. I have to put together a JSON payload that contains strings, array's, and booleans. I can't seem to find a way to convert my page item into a boolean while concatenating it with the rest of the payload. If I turn it into a variable of type = boolean, I get the error: PLS-00306: wrong number or types of arguments in call to '||' when validating the code in the apex UI. If I try to send the variables as 'True' or 'False' strings, I get the error is_diligence_attested must be a boolean. How can I successfully send these variables as booleans without harming the rest of my json body?

  • In the example, v_is_diligence_attested and v_is_bank_addendum_completed have been converted into boolean pl/sql variables.
v_json_data := '{
           "client_id":"' || :P290_CLIENT_ID || 
           '","secret":"' || :P290_SECRET || 
           '","company_name":"' || :P290_COMPANY_NAME || 
           '","address":{"city":"' || :P290_CITY || '","street":"' || :P290_STREET || '","region":"' || :P290_REGION || '","postal_code":"' || :P290_POSTAL_CODE || '","country_code":"' || :P290_COUNTRY_CODE || '"},
           "application_name":"' || :P290_APPLICATION_NAME || 
           '","legal_entity_name":"' || :P290_LEGAL_ENTITIY_NAME || 
           '","website":"' || :P290_WEBSITE ||
           '","is_diligence_attested":' || v_is_diligence_attested ||
           ',"is_bank_addendum_completed":' || v_is_bank_addendum_completed ||
           ',"products":["auth","transactions"],
           "technical_contact":{"given_name":"Snoop Dog","family_name":"The OG","email":"SWED@email.com"},
           "billing_contact":{"given_name":"Martha","family_name":"Stewart","email":"BBTG@email.com"},
           "customer_support_info":{"email":"AADD@email.com","phone_number":"111-111-1111","contact_url":"thisaurl.com","link_update_url":"updateurl.com"},
           "assets_under_management":{"amount":100,"iso_currency_code":"USD"},
           "registration_number":"100"
       }';


Solution

  •  '","is_diligence_attested":' || case when v_is_diligence_attested then 'true' else 'false' end ||