Kayshav.com
About Developer Oracle 19c Oracle 12c Technology Information Sitemap

Oracle JSON_Serialize
-- Oracle 19c: JSON_Serialize

CREATE TABLE j_purchaseorder
  (po_id          NUMBER GENERATED BY DEFAULT AS IDENTITY
                        (START WITH 1 INCREMENT BY 1) PRIMARY KEY,
   created_date   TIMESTAMP(3) WITH TIME ZONE,
   po_document    VARCHAR2(32767)
   CONSTRAINT ensure_json CHECK (po_document IS JSON (STRICT))
);

INSERT INTO j_purchaseorder
  VALUES (TO_DATE('30-DEC-2014','dd-MON-yyyy'),
          '{"PONumber"             : 1001,
            "Reference"            : "QN-141001",
            "Requestor"            : "George Lincoln",
            "User"                 : "glincoln",
            "CostCenter"           : "1600",
            "ShippingInstructions" : {"Attn:": "George",
                                      "Address":
                                         {"Street"  : "1600 Pennsylvaina Ave",
                                          "City"    : "Washington",
                                          "State"   : "DC",
                                          "ZipCode" : 20001,
                                          "Country" : "USA" },
                                      "Phone" : [ { "Type" : "Office", "number" : "100-200-3000" },
                                                  { "Type" : "Mobile", "number" : "200-300-4000" } ] 
                                     },
            "Special Instructions" : null,
            "AllowPartialShipment" : true,
            "LineItems"            : { "ItemNumber" : 1,
                                       "Part" :
                                        { "Description" : "Camera",
                                          "UnitPrice"   : 1999.95,
                                          "UPC"         : 1001001001 },
                                       "Quantity"   : 100},
                                     { "ItemNumber" : 2,
                                       "Part" : 
                                        { "Description" : "UAV",
                                          "UnitPrice"   : 99999.95,
                                          "UPC"         : 1011011011 },
                                       "Quantity"   : 10} ]
          }'
);

COMMIT;

SELECT JSON_Serialize(po_document PRETTY) 
FROM j_purchaseorder
;


  Oracle 19c Index

  Lower Versions   11g Index   12c Index

Oracle registered trademark of Oracle Corporation.

Last Revised On: January 27th, 2021

  4325