json_query

json_query(JsonDocument, Path)

The json_query extracts the object or array identified by Path from JsonDocument. Path is a varchar in the JSON Path Syntax. This will return either an object or an array value. If Path refers to a scalar no value is returned.

Assuming the same Json field from the previous examples:

json_query(Json, '$') --------------------- {"items":[{"Num":1,"Text":"The Name","First":true},{"Num":2.0,"Text":"The second one","First":false},null]}

json_query(Json, '$.items[0]') ------------------------------ {"Num":1,"Text":"The Name","First":true}

json_query(Json, '$.items') --------------------------- [{"Num":1,"Text":"The Name","First":true},{"Num":2.0,"Text":"The second one","First":false},null]

The following will return an empty string as they refer to scalars or non-existent keys.

json_query(Json, '$.items[0].Num')
json_query(Json, '$.items[1].Num')
json_query(Json, '$.items[0].Text')
json_query(Json, '$.items[0].First')
json_query(Json, '$.items[2]')


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.