Extract and transform JSON data using JMESPath expressions in an online editor and view the results in real-time
Uses JMESPath syntax for JSON data transformation and extraction. Examples: people[*].name
or people[?age > `25`].name
Mockoon is a powerful API mocking tool that makes it easy to create and manage mock APIs for prototyping and testing. With an intuitive interface, you can quickly set up mock servers, customize responses, and simulate scenarios in real-time, enhancing team collaboration and speeding up development.
This online tool allows you to extract and transform values from JSON data using JMESPath expressions. The extracted content is updated in real time as you type your expression.
This playground uses the same logic as the Mockoon features that support JMESPath syntaxes like the jmesPath
helper.
JMESPath is a query language for JSON data. It allows you to declaratively specify how to extract elements from a JSON document. JMESPath has built-in functions and powerful features for filtering, transforming, and projecting data.
JMESPath expressions consist of keys, array indices, and functions. Here are some basic examples:
Expression | Description |
---|---|
key | Access object key |
key.subkey | Access nested object |
array[0] | Access array element by index |
array[*] | Wildcard - all array elements |
array[*].key | Project - extract key from all array elements |
array[?condition] | Filter array elements |
array[:2] | Array slice - first 2 elements |
array[-1] | Last element of array |
{
"people": [
{
"name": "John",
"age": 30,
"city": "New York",
"skills": ["JavaScript", "Python", "React"]
},
{
"name": "Jane",
"age": 25,
"city": "San Francisco",
"skills": ["Java", "Spring", "Docker"]
},
{
"name": "Bob",
"age": 35,
"city": "Seattle",
"skills": ["C#", ".NET", "Azure"]
}
],
"company": {
"name": "Tech Corp",
"founded": 2010,
"locations": ["US", "UK", "Germany"]
}
}
JMESPath Expression | Result |
---|---|
people[*].name | All names from people array |
people[0].name | Name of first person |
people[?age > `25`].name | Names of people older than 25 |
people[?city == 'New York'] | People living in New York |
people[*].skills[0] | First skill of each person |
people[*].skills[] | All skills from all people (flattened) |
company.name | Company name |
company.locations[*] | All company locations |
length(people) | Number of people |
max(people[*].age) | Maximum age |
sort_by(people, &age) | People sorted by age |
JMESPath provides many built-in functions for data manipulation:
length()
, sort()
, sort_by()
, reverse()
, join()
min()
, max()
, sum()
, avg()
starts_with()
, ends_with()
, contains()
type()
, keys()
, values()
Operator | Description |
---|---|
== | Equal to |
!= | Not equal to |
< | Less than |
<= | Less than or equal to |
> | Greater than |
>= | Greater than or equal to |