jmespath: Simplest Explanation for Using the jmespath Syntax post thumbnail image

jmespath: Simplest Explanation for Using the jmespath Syntax

In this content, the most focus is let you use jmespath the fatest way.

jmespath can be used in command line for querying json objects, i.e. arg ‘–query “{jmespath }”‘ can be used in Azure CLI to query properties of returned object.

You can view more details at https://jmespath.org/tutorial.html

Now, let’s get started:

Name 'a' as root, 'b'/'c'/'d'… as a nested child in order.

Operator: based on current object type, which either:

Array

a[*].b to get value of b named property in the list
[start:stop:step] : a[0:5] get 5 items from index 0 to 5.
a[::2] get values of even indices
a[?b=='something'] to filter out 
a[*] shows full orginal structure while a[] flattens the a into a list items
a.*.b 
[a[*].b, a[*].c] | [] : join properties b and c into a flattened array.

Object

a.b to show value b only

Function: based on current context i.e. array, object or attribute

Array

length(a) show count of all items
max_by(a,&b) show the only object that have the highest value of b.

Object

n/A

Filter

a[?contains(@,'foo') == 'true'] character @ represent for the current item in a.

That’s just the end.

Thanks for reading and happy coding.

Leave a Reply

Related Post

CQRS là gì?CQRS là gì?

Table of Contents1 Motivation2 Cách hoạt động3 Event sourcing là gì?4 Cách cài đặt CQRS và Event Sourcing CQRS (viết tắt của cụm Command/Query Responsibility Segregation) định nghĩa sơ khai