Sometimes it's advantageous to get the shaped query
results as a JSON structure instead of the native EdgeDB
objects and types. Fortunately the only thing that's
needed to achieve that is to cast the result of the
query into json
:
Notice that we used a full Account.username
path
expression without abbreviations. This is because in
this context the filter
scope would be the json
being selected and not the Account
object. So an
abbreviated path would fail (json
has no links or
properties), but a fully-qualified path is still able to
be resolved to the same Account
object that we're
casting to json
.
In practice you rarely need to perform this type of json
cast explicitly. Our client libraries feature a query_json
version along with the regular query
functionality.