HWTJDEL — Delete a JSON entry
Call the HWTJDEL service to delete content from a JSON text.
Description
- number or string
- Literals true, false, or null
- JSON object or JSON array
There are several ways to obtain the handles required to delete a given JSON value, depending on the type of value being deleted. See Examples at the end of this service for pseudo-code examples.
Environment
The requirements for the caller are:
| Requirement | Details |
|---|---|
| Minimum authorization: | Supervisor state or problem state, any PSW key. |
| Dispatchable unit mode: | Task or SRB. |
| Cross memory mode: | Any PASN, any HASN, any SASN. |
| AMODE: | 31 bit. |
| ASC mode: | Primary or access register (AR). |
| Interrupt status: | Enabled for I/O and external interrupts. |
| Locks: | No locks held. |
| Control parameters: | Control parameters must be in the primary address space and addressable by the caller. |
| Linkage: | Standard MVS linkage conventions are used. |
Programming requirements
See Syntax, linkage, and programming considerations for details about how to call the z/OS® JSON parser services in the various supported programming languages.
REXX programming considerations for the HWTJDEL service
All information for the HWTJDEL service applies for REXX requests.
Syntax
Write the call as shown in the following syntax diagram. You must code all parameters in the order shown.
| Non-REXX parameters | REXX parameters |
|---|---|
|
|
Parameters
The parameters are explained as follows:
- ReturnCode
- Returned parameter.
- Type: Integer (non-REXX), character representation of an integer (REXX)
- Length: 4 bytes (non-REXX)
- ParserHandle
- Supplied parameter.
- Type: Character string
- Length: 12 bytes (non-REXX)
- ObjectHandle
- Supplied parameter.
- Type: Integer (non-REXX), character representation of an integer (REXX)
- Length: 4 bytes (non-REXX)
- EntryValueHandle
- Supplied parameter.
- Type: Integer (non-REXX), character representation of an integer (REXX)
- Length: 4 bytes (non-REXX)
- DiagArea (non-REXX)
- DiagArea. (REXX)
- Returned parameter.
- Type: Character string (non-REXX), stem variable (REXX)
- Length: 132 bytes (non-REXX)
ABEND codes
X'04D' ABEND with a reason code of
X'000Eyyyy' for one of the following reasons: - yyyy
- Reason
- 0000
- The parameters passed by the caller are not in the primary address space.
- 0001
- The number of parameters passed by the caller is incorrect.
Return codes
|
Hexadecimal return code
Equate symbol |
Meaning and action |
|---|---|
|
0
HWTJ_OK |
Meaning: Successful
completion. Action: None. |
|
101
HWTJ_PARSERHANDLE_INV |
Meaning: Program error. The
parserHandle parameter specified on the service call is not a valid parser
handle (one that was returned by the HWTJINIT service). Action: Check for a probable coding error. |
|
102
HWTJ_PARSERHANDLE_INUSE |
Meaning: Program error. Two possible reasons can result
in this return code:
Action: Check for a probable coding error.
|
|
103
HWTJ_INACCESSIBLE_PARM |
Meaning: Program error. The application passed an input
or output parameter which was inaccessible by the parser. See General programming considerations for details about z/OS JSON parser
recovery processing. Action: Check for a probable coding error. Likely, the
recovery of the caller detected this return code as a result of the parser abnormally ending with a
|
|
104
HWTJ_HANDLE_INV |
Meaning: Program error. The value specified for the
objectHandle or entryValueHandle parameter is not
valid. Action: Check for a probable coding error. (For example, uninitialized handle or a reference to a deleted entry.) |
|
105
HWTJ_HANDLE_TYPE_ERROR |
Meaning: Program error. The specified
objectHandle does not represent an object or array object (JSON type of
HWTJ_OBJECT_TYPE or
HWTJ_ARRAY_TYPE). Action: Check for a probable coding error. Specify a handle that represents a JSON object or JSON array. |
|
901
HWTJ_JDEL_ENTRY_NOTE_FOUND |
Meaning: Program error. The specified
entryValueHandle does not represent an entry contained within the object
specified by objectHandle Action: Check for a probable coding error. |
|
F01
HWTJ_INTERRUPT_STATUS_INV |
Meaning: Program error. The calling program is
disabled. The system rejects the service request. Action: Check the calling program for a probable coding error. |
|
F02
HWTJ_LOCKS_HELD |
Meaning: Program error. The calling program is holding
one or more locks. The system rejects the service request. Action: Check the calling program for a probable coding error. |
|
F03
HWTJ_UNSUPPORTED_RELEASE |
Meaning: The operating system level does not support
this service. The system rejects the service request. Action: Remove the calling program from this system, install it on a system that supports z/OS JSON parser services, and run the calling program again. |
|
FFF
HWTJ_UNEXPECTED_ERROR |
Meaning: System error. The service encountered an
unexpected error. The system rejects the service call. Action: Search problem reporting databases for a fix for the problem. If no fix exists, contact the IBM Support Center. |
Examples
The following pseudo-code examples demonstrate several uses of HWTJDEL.
Example 1:
Given the following JSON text:
{
"foo":{
"mood":"happy",
"color":"red",
"bling":"baz"
},
"bar":[ "bag", 3, true]
}
To delete the "mood" entry from the "foo" object, first call HWTJSRCH to obtain a handle to the "foo" object.
objectName = "foo"
rootObject = 0 /* search the root object */
startingHandle = 0 /* start with the first member */
HWTJSRCH (
returnCode,
parserHandle,
HWTJ_SEARCHTYPE_GLOBAL,
objectName,
length(objectName),
rootObject,
startingHandle,
targetObjectHandle,
DiagArea
);
The output handle (targetObjectHandle) can then be used on a subsequent call to HWTJSRCH to find the "mood" entry.
entryName = "mood"
HWTJSRCH (
returnCode,
parserHandle,
HWTJ_SEARCHTYPE_OBJECT,
entryName,
length(entryName),
targetObjectHandle,
startingHandle,
targetEntryHandle,
diagArea
);
Having obtained the required targetObjectHandle and targetEntryHandle, a call to HWTJDEL would look similar to this:
HWTJDEL(
returnCode,
parserHandle,
targetObjectHandle,
targetEntryHandle,
diagArea
);
A subsequent call to HWTJSERI would return a JSON text string reflecting the delete operation.
{
"foo":{
"color":"red",
"bling":"baz"
},
"bar":[ "bag", 3, true]
}
Example 2:
Deleting an element from a JSON array would require a slightly different sequence of operations.
Given the following JSON text:
{
"bar":[ "bag", 3, true, {"a": "somewhere"} ],
"bling": "blam",
"pi": 3.14159
}
To delete the fourth entry (the object with a single entry named "a") from the "bar" array , first call HWTJSRCH to obtain a handle to the "bar" array.
arrayName = "bar"
rootObject = 0 /* Search the root */
startingHandle = 0 /* Start at the first member */
targetArrayHandle = 0
HWTJSRCH (
returnCode,
parserHandle,
HWTJ_SEARCHTYPE_GLOBAL,
arrayName,
length(arrayName),
rootObject,
startHandle,
targetArrayHandle,
DiagArea
);
The output handle (targetArrayHandle) can then be used on a subsequent call to HWTJGAEN to retrieve a handle to the fourth array value.
entryIndex = 3 /* Note that array entries are zero-indexed */
HWTJGAEN (
returnCode,
parserHandle,
targetArrayHandle,
entryIndex,
targetEntryHandle,
diagArea
);
Having obtained the required targetArrayHandle and targetEntryHandle, a call to HWTJDEL would look similar to this:
HWTJDEL(
returnCode,
parserHandle,
targetArrayHandle,
targetEntryHandle,
diagArea
);
{
"bar":[ "bag", 3, true ],
"bling": "blam",
"pi": 3.14159
}