Closed UNC1739 closed 1 year ago
My interpretation of one of the early (maybe original) description of JSONPath (https://goessner.net/articles/JsonPath) is that the element in a union can be either numbers which are treated as indexes or names which would be quoted. I know the owner of the jsonpath.com domain has a nice evaluator but that does not make it a standard. There is quite a range of interpretations of what JSONPath is as you can see from https://cburgmer.github.io/json-path-comparison. Anyway to cut the story short, the way OjG expects a union like you want would be:
$.additionalDetails.ResourceDescription.Properties['WebsiteURL','DualStackDomainName']
I did not test with your example but there are similar, albeit simpler, tests in the jp/get_test.go file.
Thanks @ohler55! That worked for what I was trying to accomplish.
Does the JSONPath implementation within the OJG library support extracting multiple values from different keys within the same JSONPath query? I haven't been able to find a way to do this using the library, unfortunately. I've got a quick example I can provide if that helps.
Below is some example JSON data that contains information about an AWS S3 bucket.
I've written the following JSONPath query to extract this data:
I've found using an online JSONPath tool (jsonpath.com) that this query when run against the previously provided sample data produces the following result:
However, when using the OJG library I'm not getting any results back from this JSONPath query. Below is the sample code I'm using:
Below is the output from running this program: