|
From what I've read of JSON_TABLE and it's options ( such as NULL ON EMPTYetc ) it is about looking for a specific element using a path and what to
Hi All,
I've written quite a lot of code using the DB2 JSON functions and it works
pretty well.
I've been using JSON_TABLE in lax mode and checking null indicators for
any mandatory keys.
But I've been concerned that with this approach, any misspelled optional
keys just get lost.
So I've started trying to use strict mode.
But unless I am missing something, I think that strict mode insists on all
specified keys to be present in the object.
Does anyone know if there is a way of using JSON_TABLE() such that absent
keys are just treated as null but misspelled keys are reported as errors?
For example:
I would like:
Select t1.ItemRef,
t1.ManuDate,
t1.AltRef,
t1.Grade
From WsInq00 t2,
JSON_TABLE(
t2.RqsText,
'strict $'
ERROR ON ERROR
COLUMNS(
ItemRef CHAR( 20 ) PATH 'strict $.itemRef',
ManuDate CHAR( 10 ) PATH 'strict $.manuDate'
AltRef CHAR( 30 ) PATH 'strict $.altRef',
Grade CHAR( 3 ) PATH 'strict $.grade'
)
) as t1
Where t2.UniqueID = 100982;
to accept this:
{
"itemRef": "SRSWLVB5GZWYS33LP9MQ",
"grade": "8EY"
}
because all *present *fields are correct keys
but reject this:
{
"itemRef": "SRSWLVB5GZWYS33LP9MQ",
"Grade": "8EY"
}
Because the Grade key is spelled with a capitol G and it should not be.
Is there a way of achieving this?
Thanks kindly,
Craig
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.