PL/JSON


Object Type PLJSON_VALUE

Underlying type for all of PL/JSON. Each pljson or pljson_list object is composed of pljson_value objects.

Generally, you should not need to directly use the constructors provided by this portion of the API. The methods on pljson and pljson_list should be used instead.


Field Summary
 CLOBEXTENDED_STR
           Private variable for internal processing.
 NUMBER(32)MAPINDX
           Private variable for internal processing.
 VARCHAR2(4000)MAPNAME
           Private variable for internal processing.
 NUMBERNUM
           Private variable for internal processing.
 BINARY_DOUBLENUM_DOUBLE
           Private variable for internal processing.
 VARCHAR2(1)NUM_REPR_DOUBLE_P
           Private variable for internal processing.
 VARCHAR2(1)NUM_REPR_NUMBER_P
           Private variable for internal processing.
 PLJSON_ELEMENTOBJECT_OR_ARRAY
           Private variable for internal processing.
 VARCHAR2(32767)STR
           Private variable for internal processing.
 NUMBER(1)TYPEVAL
          

Internal property that indicates the JSON type represented:

  1. object
  2. array
  3. string
  4. number
  5. bool
  6. null

Method Summary
 MEMBER FUNCTION BOOLEAN GET_BOOL()
          

Retrieve the value as a boolean.

 MEMBER FUNCTION BINARY_DOUBLE GET_DOUBLE()
          

Retrieve the value as a binary_double.

 MEMBER FUNCTION PLJSON_ELEMENT GET_ELEMENT()
          
 MEMBER FUNCTION VARCHAR2 GET_NULL()
          

Retrieve the value as a string 'null'.

 MEMBER FUNCTION NUMBER GET_NUMBER()
          

Retrieve the value as a number.

 MEMBER FUNCTION VARCHAR2 GET_STRING(MAX_BYTE_SIZE IN NUMBER DEFAULT NULL, MAX_CHAR_SIZE IN NUMBER DEFAULT NULL)
          

Retrieve the value as a string (varchar2).

 MEMBER PROCEDURE GET_STRING(SELF IN PLJSON_VALUE, BUF IN OUT NOCOPY CLOB)
          

Retrieve the value as a string represented by a CLOB.

 MEMBER FUNCTION VARCHAR2 GET_TYPE()
          

Retrieve the name of the type represented by the pljson_value.

Possible return values:

  • object
  • array
  • string
  • number
  • bool
  • null
 MEMBER PROCEDURE HTP(SELF IN PLJSON_VALUE, SPACES IN BOOLEAN DEFAULT FALSE, CHARS_PER_LINE IN NUMBER DEFAULT 0, JSONP IN VARCHAR2 DEFAULT NULL)
          
 MEMBER FUNCTION BOOLEAN IS_ARRAY()
          

Determine if the value represents an "array" type.

 MEMBER FUNCTION BOOLEAN IS_BOOL()
          

Determine if the value represents a "boolean" type.

 MEMBER FUNCTION BOOLEAN IS_NULL()
          

Determine if the value represents a "null" type.

 MEMBER FUNCTION BOOLEAN IS_NUMBER()
          

Determine if the value represents a "number" type.

 MEMBER FUNCTION BOOLEAN IS_NUMBER_REPR_DOUBLE()
           Private method for internal processing.
 MEMBER FUNCTION BOOLEAN IS_NUMBER_REPR_NUMBER()
           Private method for internal processing.
 MEMBER FUNCTION BOOLEAN IS_OBJECT()
          

Determine if the value represents an "object" type.

 MEMBER FUNCTION BOOLEAN IS_STRING()
          

Determine if the value represents a "string" type.

 STATIC FUNCTION PLJSON_VALUE MAKENULL()
          

Create an empty pljson_value.

 declare
   myval pljson_value := pljson_value.makenull();
 begin
   myval.parse_number('42');
   myval.print(); // => dbms_output.put_line('42');
 end;
 
 MEMBER FUNCTION VARCHAR2 NUMBER_TOSTRING()
          

Return a varchar2 representation of a number type.

 MEMBER PROCEDURE PARSE_NUMBER(STR IN VARCHAR2)
          

Parses a string into a number.

 CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(ELEM IN PLJSON_ELEMENT)
          
 CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(STR IN VARCHAR2, ESC IN BOOLEAN DEFAULT TRUE)
          
 CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(STR IN CLOB, ESC IN BOOLEAN DEFAULT TRUE)
          
 CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(NUM IN NUMBER)
          
 CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(NUM_DOUBLE IN BINARY_DOUBLE)
          
 CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(B IN BOOLEAN)
          
 CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE()
          
 MEMBER PROCEDURE PRINT(SELF IN PLJSON_VALUE, SPACES IN BOOLEAN DEFAULT TRUE, CHARS_PER_LINE IN NUMBER DEFAULT 8192, JSONP IN VARCHAR2 DEFAULT NULL)
          
 MEMBER FUNCTION VARCHAR2 TO_CHAR(SPACES IN BOOLEAN DEFAULT TRUE, CHARS_PER_LINE IN NUMBER DEFAULT 0)
          
 MEMBER PROCEDURE TO_CLOB(SELF IN PLJSON_VALUE, BUF IN OUT NOCOPY CLOB, SPACES IN BOOLEAN DEFAULT FALSE, CHARS_PER_LINE IN NUMBER DEFAULT 0, ERASE_CLOB IN BOOLEAN DEFAULT TRUE)
          
 MEMBER FUNCTION VARCHAR2 VALUE_OF(SELF IN PLJSON_VALUE, MAX_BYTE_SIZE IN NUMBER DEFAULT NULL, MAX_CHAR_SIZE IN NUMBER DEFAULT NULL)
          

Field Detail

EXTENDED_STR

        public CLOB EXTENDED_STR
Private variable for internal processing.

MAPINDX

        public NUMBER(32) MAPINDX
Private variable for internal processing.

MAPNAME

        public VARCHAR2(4000) MAPNAME
Private variable for internal processing.

NUM

        public NUMBER NUM
Private variable for internal processing.

NUM_DOUBLE

        public BINARY_DOUBLE NUM_DOUBLE
Private variable for internal processing.

NUM_REPR_DOUBLE_P

        public VARCHAR2(1) NUM_REPR_DOUBLE_P
Private variable for internal processing.

NUM_REPR_NUMBER_P

        public VARCHAR2(1) NUM_REPR_NUMBER_P
Private variable for internal processing.

OBJECT_OR_ARRAY

        public PLJSON_ELEMENT OBJECT_OR_ARRAY
Private variable for internal processing.

STR

        public VARCHAR2(32767) STR
Private variable for internal processing.

TYPEVAL

        public NUMBER(1) TYPEVAL

Internal property that indicates the JSON type represented:

  1. object
  2. array
  3. string
  4. number
  5. bool
  6. null

Method Detail

GET_BOOL

public MEMBER FUNCTION BOOLEAN GET_BOOL()

Retrieve the value as a boolean.

Returns:
An instance of boolean or null if the value isn't a boolean.


GET_DOUBLE

public MEMBER FUNCTION BINARY_DOUBLE GET_DOUBLE()

Retrieve the value as a binary_double.

Returns:
An instance of binary_double or null if the value isn't a number.


GET_ELEMENT

public MEMBER FUNCTION PLJSON_ELEMENT GET_ELEMENT()


GET_NULL

public MEMBER FUNCTION VARCHAR2 GET_NULL()

Retrieve the value as a string 'null'.

Returns:
A varchar2 with the value 'null' or an actual null if the value isn't a JSON "null".


GET_NUMBER

public MEMBER FUNCTION NUMBER GET_NUMBER()

Retrieve the value as a number.

Returns:
An instance of number or null if the value isn't a number.


GET_STRING

public MEMBER FUNCTION VARCHAR2 GET_STRING(MAX_BYTE_SIZE IN NUMBER DEFAULT NULL, 
MAX_CHAR_SIZE IN NUMBER DEFAULT NULL)

Retrieve the value as a string (varchar2).

Parameters:
MAX_BYTE_SIZE - Retreive the value up to a specific number of bytes. Default: null.
MAX_CHAR_SIZE - Retrieve the value up to a specific number of characters. Default: null.
Returns:
An instance of varchar2 or null value is not a string.


GET_STRING

public MEMBER PROCEDURE GET_STRING(SELF IN PLJSON_VALUE, 
BUF IN OUT NOCOPY CLOB)

Retrieve the value as a string represented by a CLOB.

Parameters:
BUF - The CLOB in which to store the string.


GET_TYPE

public MEMBER FUNCTION VARCHAR2 GET_TYPE()

Retrieve the name of the type represented by the pljson_value.

Possible return values:

  • object
  • array
  • string
  • number
  • bool
  • null
Returns:
The name of the type represented.


HTP

public MEMBER PROCEDURE HTP(SELF IN PLJSON_VALUE, 
SPACES IN BOOLEAN DEFAULT FALSE,
CHARS_PER_LINE IN NUMBER DEFAULT 0,
JSONP IN VARCHAR2 DEFAULT NULL)


IS_ARRAY

public MEMBER FUNCTION BOOLEAN IS_ARRAY()

Determine if the value represents an "array" type.

Returns:
true if the value is an array, false otherwise.


IS_BOOL

public MEMBER FUNCTION BOOLEAN IS_BOOL()

Determine if the value represents a "boolean" type.

Returns:
true if the value is a boolean, false otherwise.


IS_NULL

public MEMBER FUNCTION BOOLEAN IS_NULL()

Determine if the value represents a "null" type.

Returns:
true if the value is a null, false otherwise.


IS_NUMBER

public MEMBER FUNCTION BOOLEAN IS_NUMBER()

Determine if the value represents a "number" type.

Returns:
true if the value is a number, false otherwise.


IS_NUMBER_REPR_DOUBLE

public MEMBER FUNCTION BOOLEAN IS_NUMBER_REPR_DOUBLE()
Private method for internal processing.


IS_NUMBER_REPR_NUMBER

public MEMBER FUNCTION BOOLEAN IS_NUMBER_REPR_NUMBER()
Private method for internal processing.


IS_OBJECT

public MEMBER FUNCTION BOOLEAN IS_OBJECT()

Determine if the value represents an "object" type.

Returns:
true if the value is an object, false otherwise.


IS_STRING

public MEMBER FUNCTION BOOLEAN IS_STRING()

Determine if the value represents a "string" type.

Returns:
true if the value is a string, false otherwise.


MAKENULL

public STATIC FUNCTION PLJSON_VALUE MAKENULL()

Create an empty pljson_value.

 declare
   myval pljson_value := pljson_value.makenull();
 begin
   myval.parse_number('42');
   myval.print(); // => dbms_output.put_line('42');
 end;
 
Returns:
An instance of pljson_value.


NUMBER_TOSTRING

public MEMBER FUNCTION VARCHAR2 NUMBER_TOSTRING()

Return a varchar2 representation of a number type. This is primarily intended to be used within PL/JSON internally.

Returns:
A varchar2 up to 4000 characters.


PARSE_NUMBER

public MEMBER PROCEDURE PARSE_NUMBER(STR IN VARCHAR2)

Parses a string into a number. This method will automatically cast to a binary_double if it is necessary.

 declare
   mynum pljson_value := pljson_value('42');
 begin
   dbms_output.put_line('mynum is a string: ' || mynum.is_string()); // 'true'
   mynum.parse_number('42');
   dbms_output.put_line('mynum is a number: ' || mynum.is_number()); // 'true'
 end;
 
Parameters:
STR - A varchar2 to parse into a number.


PLJSON_VALUE

public CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(ELEM IN PLJSON_ELEMENT)


PLJSON_VALUE

public CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(STR IN VARCHAR2, 
ESC IN BOOLEAN DEFAULT TRUE)


PLJSON_VALUE

public CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(STR IN CLOB, 
ESC IN BOOLEAN DEFAULT TRUE)


PLJSON_VALUE

public CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(NUM IN NUMBER)


PLJSON_VALUE

public CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(NUM_DOUBLE IN BINARY_DOUBLE)


PLJSON_VALUE

public CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE(B IN BOOLEAN)


PLJSON_VALUE

public CONSTRUCTOR FUNCTION SELF AS RESULT PLJSON_VALUE()


PRINT

public MEMBER PROCEDURE PRINT(SELF IN PLJSON_VALUE, 
SPACES IN BOOLEAN DEFAULT TRUE,
CHARS_PER_LINE IN NUMBER DEFAULT 8192,
JSONP IN VARCHAR2 DEFAULT NULL)


TO_CHAR

public MEMBER FUNCTION VARCHAR2 TO_CHAR(SPACES IN BOOLEAN DEFAULT TRUE, 
CHARS_PER_LINE IN NUMBER DEFAULT 0)


TO_CLOB

public MEMBER PROCEDURE TO_CLOB(SELF IN PLJSON_VALUE, 
BUF IN OUT NOCOPY CLOB,
SPACES IN BOOLEAN DEFAULT FALSE,
CHARS_PER_LINE IN NUMBER DEFAULT 0,
ERASE_CLOB IN BOOLEAN DEFAULT TRUE)


VALUE_OF

public MEMBER FUNCTION VARCHAR2 VALUE_OF(SELF IN PLJSON_VALUE, 
MAX_BYTE_SIZE IN NUMBER DEFAULT NULL,
MAX_CHAR_SIZE IN NUMBER DEFAULT NULL)


PL/JSON