πΉ About
JSON (JavaScript Object Notation) has become the standard format for modern web applications and APIs.
In modern enterprise applications, developers frequently work with:
β
REST APIs
β
Mobile applications
β
Third-party integrations
β
Dynamic front-end applications
β
AI & cloud services
Oracle Database and Oracle APEX provide powerful native support for JSON operations.
In this blog, weβll learn:
β What is JSON
β JSON support in Oracle Database
β JSON functions in SQL
β Working with JSON in Oracle APEX
β Real-time API integration example
π οΈ Tools and Technologies
- Oracle Database
- Oracle APEX
- SQL
- PL/SQL
- REST APIs
- JSON
π What is JSON?
JSON stands for:
JavaScript Object NotationIt is a lightweight data exchange format used between applications and APIs.
π Example JSON
{
"empno": 101,
"ename": "Ankur",
"job": "Developer",
"salary": 5000
}π― Why JSON is Important?
JSON is widely used because:
β
Lightweight
β
Easy to read
β
API friendly
β
Language independent
β
Fast data exchange
π JSON Support in Oracle Database
Oracle Database provides native JSON support using:
β
JSON data type
β
JSON_OBJECT
β
JSON_ARRAY
β
JSON_TABLE
β
JSON_VALUE
β
JSON_QUERY
π Creating Table with JSON Column
CREATE TABLE employee_json
(
emp_id NUMBER,
emp_data CLOB CHECK (emp_data IS JSON)
);π Insert JSON Data
INSERT INTO employee_json
VALUES (
1,
'{
"ename":"Ankur",
"job":"Developer",
"salary":5000
}'
);π Fetch Complete JSON
SELECT emp_data
FROM employee_json;π Extract JSON Value
Use:
JSON_VALUEExample:
SELECT
JSON_VALUE(emp_data, '$.ename') AS employee_name,
JSON_VALUE(emp_data, '$.job') AS employee_job
FROM employee_json;π Extract JSON Object
Use:
JSON_QUERYExample:
SELECT JSON_QUERY(emp_data, '$')
FROM employee_json;π Convert Table Data to JSON
Oracle can generate JSON directly from SQL.
π Example Using JSON_OBJECT
SELECT JSON_OBJECT(
'empno' VALUE empno,
'ename' VALUE ename,
'job' VALUE job
) AS employee_json
FROM emp;π Generate JSON Array
SELECT JSON_ARRAYAGG(
JSON_OBJECT(
'empno' VALUE empno,
'ename' VALUE ename
)
) AS employees
FROM emp;π Real-Time Example: Employee Directory API in Oracle APEX
Now letβs build a practical real-time example.
π― Scenario
Suppose we want to:
β
Generate employee data as JSON
β
Expose it via REST API
β
Consume the JSON in Oracle APEX
β
Display dynamic employee cards
π Step 1: Create REST API Query
Go to:
SQL Workshop β RESTful ServicesCreate Module:
employee_apiπ SQL Query
SELECT JSON_ARRAYAGG(
JSON_OBJECT(
'empno' VALUE empno,
'ename' VALUE ename,
'job' VALUE job,
'salary' VALUE sal
)
) AS employee_data
FROM emp;π Sample API Response
[
{
"empno":7369,
"ename":"SMITH",
"job":"CLERK",
"salary":800
},
{
"empno":7499,
"ename":"ALLEN",
"job":"SALESMAN",
"salary":1600
}
]π Step 2: Consume JSON API in Oracle APEX
Create a region:
Create Page β Cardsπ Data Source Type
Set:
REST Data SourceUse your API endpoint.
π Map JSON Columns
| JSON Field | Card Attribute |
|---|---|
| ename | Title |
| job | Subtitle |
| salary | Body |
π Step 3: Add Dynamic Styling
Go to:
Cards β Appearance β HTML Expressionπ Example
<div class="emp-card">
<h3>#ENAME#</h3>
<p>#JOB#</p>
{if SALARY/}
<span class="t-Badge t-Badge--success">
Salary: #SALARY#
</span>
{endif/}
</div>π Step 4: Add Custom CSS
Go to:
Page β CSS β Inlineπ CSS
.emp-card {
padding: 15px;
border-radius: 12px;
background: #f8f9fa;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}π Working with JSON_TABLE
JSON_TABLE converts JSON into relational rows.
π Example
SELECT *
FROM JSON_TABLE(
'[
{"name":"Ankur","salary":5000},
{"name":"Ravi","salary":7000}
]',
'$[*]'
COLUMNS (
employee_name VARCHAR2(50) PATH '$.name',
salary NUMBER PATH '$.salary'
)
);π Output
| EMPLOYEE_NAME | SALARY |
|---|---|
| Ankur | 5000 |
| Ravi | 7000 |
π Working with APEX_JSON Package
Oracle APEX provides:
APEX_JSONpackage for JSON processing.
π Example
DECLARE
l_json CLOB;
BEGIN
APEX_JSON.initialize_clob_output;
APEX_JSON.open_object;
APEX_JSON.write('ename', 'Ankur');
APEX_JSON.write('job', 'Developer');
APEX_JSON.close_object;
l_json := APEX_JSON.get_clob_output;
DBMS_OUTPUT.put_line(l_json);
END;π Output
{
"ename":"Ankur",
"job":"Developer"
}π Real-World Use Cases
JSON is heavily used in:
β REST APIs
β Mobile applications
β AI integrations
β Cloud applications
β External system integrations
β Dynamic dashboards
π Example Architecture
Oracle Database
β
Generate JSON
β
REST API
β
Oracle APEX
β
Dynamic UI Renderingβ οΈ Important Considerations
πΉ Validate JSON
Always validate JSON before storing.
πΉ Use JSON Indexing
For large JSON datasets:
β Use JSON Search Index
to improve performance.
πΉ Avoid Large Nested JSON
Very complex JSON structures may impact performance.
π Advantages of JSON in Oracle
β
Native support
β
High performance
β
API friendly
β
Flexible structure
β
Easy integration
π― Why Oracle APEX Developers Love JSON
JSON makes it easy to integrate Oracle APEX with:
β External APIs
β JavaScript frameworks
β Mobile apps
β Cloud services
without complicated transformations.
π Conclusion
JSON has become an essential part of modern application development.
With Oracle Database and Oracle APEX, developers can easily:
β
Store JSON
β
Generate JSON
β
Parse JSON
β
Consume REST APIs
β
Build dynamic applications
Whether you are integrating external services or building modern enterprise apps, mastering JSON in Oracle and APEX is a must-have skill.
Happy Coding! π
Hi, Iβm Ankur Rai, an Oracle APEX Developer with 6+ years of professional experience in building enterprise applications. I specialize in creating scalable and efficient solutions using Oracle APEX, PL/SQL, and SQL to solve real-world business challenges.
I am a 3X Oracle APEX Professional Certified Developer and also an Oracle ACE Associate Member, actively contributing to the Oracle community by sharing knowledge, insights, and best practices. Through my blogs, I aim to help developers learn, grow, and build better Oracle APEX applications together.




