got it to work - and yes Daniel I totally agree that providing the json
would have been more helpful - sorry I couldn't was just too big with too
much sensitive data...

this is what I was looking for...

select *
from *json_table*(jvaughn.tempjson1
,'$'
Columns (orders *varchar*(*32000*) format json Path
'$.orders'
,nested '$.orders[*]'
Columns("dtNr" *char*(*10*)
)
)
) as t
where "dtNr" = '78714';


Jay

On Wed, Jul 16, 2025 at 7:48 AM Jay Vaughn <jeffersonvaughn@xxxxxxxxx>
wrote:

Daniel - silly of me thinking ArrayData was some kind of reserved word...
But the answer to your question is in the path... the key name of the
array is orders.

so If I replace ArrayData with "orders" - I still get null...


Select *
From *JSON_TABLE*(jvaughn.tempjson1
,'$' columns(NESTED '$.orders[*]'
Columns("dtNr" *char*(*10*)
,"orders" *VarChar*(*32000*
) format json Path '$.orders'
)
)
)
where "dtNr" = '78714';


thanks

Jay







On Wed, Jul 16, 2025 at 12:02 AM Daniel Gross <daniel@xxxxxxxx> wrote:

So what's the "name" (key) of the JSON element containing the array?
Really "ArrayData"? Maybe the JSON path '$.orders' of the element is wrong?

Without seeing at least some part of the structure it's hard to say where
the error is. From what you write, it seems like it looks like this:

{
"orders":[
"drNr":"xxxxxx",
"ArrayData:[
...
]
]
}

That the "dtNr" column is populated is a good sign - so it seems correct
until there.

Regards,
Daniel

Am 15.07.2025 um 22:57 schrieb Jay Vaughn <jeffersonvaughn@xxxxxxxxx>:

this is great Birgitta (or anyone avail to answer)...

but my arraydata comes back null... however my dtNr is found! I need
the
associated array that dtNr is found in...

Select *
From *JSON_TABLE*(jvaughn.tempjson1
,'$' columns(NESTED '$.orders[*]'
Columns("dtNr" *char*(*10*)
,ArrayData
*VarChar*(*32000*)
format json Path '$.orders'
)
)
)
where "dtNr" = '78714';



tia

Jay

On Tue, Jul 15, 2025 at 4:26 PM Jay Vaughn <jeffersonvaughn@xxxxxxxxx>
wrote:

I actually think I got it...

lots of thanks Birgitta!

Jay

On Tue, Jul 15, 2025 at 4:06 PM Jay Vaughn <jeffersonvaughn@xxxxxxxxx>
wrote:

thank - this looks like interesting stuff I've never used before so I
have hope...

however both of these statements fail as-is (when replacing
json_document
with my actual json resource)

Jay

On Tue, Jul 15, 2025 at 1:01 PM Birgitta Hauser <
Hauser@xxxxxxxxxxxxxxx>
wrote:

If you only want to have a string, that contains everything in an
object
or array, you just have to add FORMAT JSON:

Select *
From JSON_TABLE(Json-Document, '$'
Columns(ArrayData VarChar(4096) FORMAT JSON Path
'$.Orders');

You Could also use JSON_QUERY.

Values(JSON_Query(Json_Document FORMAT JSON '$.Orders');


Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization – Education – Consulting on IBM i
Database and Software Architect
IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars."
(Les Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training
them and keeping them!"
"Train people well enough so they can leave, treat them well enough
so
they don't want to. " (Richard Branson)
"Learning is experience … everything else is only information!"
(Albert
Einstein)


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf
Of
Jay Vaughn
Sent: Tuesday, 15 July 2025 18:48
To: Midrange Systems Technical Discussion <
midrange-l@xxxxxxxxxxxxxxxxxx

Subject: Re: json_table - get entire array

Birgitta,

Yes, and you are kinda making the point for me.
That could get quite verbose based on everything under this single
json
I'm targeting.
So was hoping for a simple way to just point at that array (which I'm
doing in my statement), and then say, bring it all back as a string
(for
example)

thanks

Jay

On Tue, Jul 15, 2025 at 12:29 PM Birgitta Hauser <
Hauser@xxxxxxxxxxxxxxx

wrote:

It would have been helpful to see the JASON ... have you tried this:

select *
from *json_table*(*trim*(jvaughn.tempjson1)
, '$.Orders[*]'
Columns (Column1 ... Path ...,
Column2 ... Path ...,
Nested $.Positions[*]
Columns(....)
)
) as t
where "dtNr" = '78714';

Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization – Education – Consulting on IBM i Database and
Software
Architect IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars."
(Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not
training
them and keeping them!"
"Train people well enough so they can leave, treat them well enough
so
they don't want to. " (Richard Branson) "Learning is experience …
everything else is only information!" (Albert
Einstein)


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf
Of
Jay Vaughn
Sent: Tuesday, 15 July 2025 17:55
To: Midrange Systems Technical Discussion
<midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: json_table - get entire array

I'm curious about a concept with json_table...

Given the below statement (which is invalid due to the
"columns('$')")...
Is there any possible way to have the statement select the entire
orders array, sub array/objects, etc, without having to define that
entire array/subarray/objects DS for that orders array?

select *
from *json_table*(*trim*(jvaughn.tempjson1)
,'$' columns(NESTED '$.orders[*]'
columns('$')
)
) as t
where "dtNr" = '78714';

tia

Jay V
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 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.