I would like to know if there is a way i could get the size of the array of a specific node in a JSON data.
As an example, below is the JSON.
For the node 'Phone' there are two items. I would like to know the size of this node. My objective is to parse the Java Array to a Java Array. If i am not aware of the size of the array i would not be able to parse.
Essentially i would like to get the value "2".
{"PONumber" : 1600,
"Reference" : "ABULL-20140421",
"Requestor" : "Alexis Bull",
"User" : "ABULL",
"CostCenter" : "A50",
"ShippingInstructions" : {"name" : "Alexis Bull",
"Address": {"street" : "200 Sporting Green",
"city" : "South San Francisco",
"state" : "CA",
"zipCode" : 99236,
"country" : "United States of America"},
"Phone" : [{"type" : "Office", "number" : "909-555-7307"},
{"type" : "Mobile", "number" : "415-555-1234"}]},
"Special Instructions" : null,
"AllowPartialShipment" : true,
"LineItems" : [{"ItemNumber" : 1,
"Part" : {"Description" : "One Magic Christmas",
"UnitPrice" : 19.95,
"UPCCode" : 13131092899},
"Quantity" : 9.0},
{"ItemNumber" : 2,
"Part" : {"Description" : "Lethal Weapon",
"UnitPrice" : 19.95,
"UPCCode" : 85391628927},
"Quantity" : 5.0}]}
As an alternative, Using the below code i would get that data :
SELECT jt.phones
FROM j_purchaseorder,
JSON_TABLE(po_document, '$.ShippingInstructions'
COLUMNS
(phones VARCHAR2(100) FORMAT JSON PATH '$.Phone')) AS jt;
however if i use
SELECT jt.phones
FROM j_purchaseorder,
JSON_TABLE(po_document, '$'
COLUMNS
(ShippingInstructions VARCHAR2(100) FORMAT JSON PATH '$.ShippingInstructions')) AS jt;
i am getting the value as null. So how can i get the entire ShippingInstructions in a single value.