I don't know what else you might need to do with the document, but when I have a complex document and I just want to extract a single item from it, I often use JsonPath.
With JsonPath you describe a path through the document to the location of the items of interest. The downside is that is has a significant learning curve, and you can spend a lot of time in the beginning trying to form the expression that fits your needs. There are on-line evaluators however which can help by showing you the results of the expression as you type (
https://jsonpath.com/ and
https://jsonpath.curiousconcept.com/#).
It may not be a good solution for what you are working on now, but it might be useful with some future project.
Here's an example (JSON document abbreviated):
Example console output (long lines shortened):
The first expression
$[0].def[0].sseq[*][0][1].dt[0][1] breaks-down like this:
$[0] first element in document
def[0] contents of first occurance of
def
sseq[*] contents of all occurrances of
sseq
[0] contents of first container
[1] contents of second container (
sense)
dt[0] contents of first occurance of
dt
[1] value of second item
The secondexpression
$[0].def[0].sseq[?(@[0][1].sn == '2')][0][1].dt[0][1] includes a filter to only include contents where
sn has a value of
2.
These are the dependencies that I used: