Resolve the nested objects with get_object calls:
declare
json_doc json_object_t;
payment_method_type varchar2(10);
begin
json_doc := json_object_t.parse('{
"test": "test",
"data": {
"id": "PefqUBaJ2FJYLHmfoeCjkDn8",
"type": "payment_method",
"attributes": {
"payment_method_type": "CNP",
"details": {
"card_brand": "Visa",
"name_on_card": "Mark Swarts",
"expiration_month": "10",
"expiration_year": "2020",
"billing_zip_code": "14225",
"last_4_digits": "1111"
},
"affiliate_reference_id": null,
"expiration": null,
"auto_update": false
},
"relationships": {
"transactions": {
"data": []
}
}
}
}');
payment_method_type := json_doc.get_object('data').get_object('attributes').get_String('payment_method_type');
dbms_output.put_line('payment_method_type: ' || payment_method_type);
end;
/
payment_method_type: CNP