Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Start by opening a new browser window and navigating to https://try.jsonata.org. The page is broken down into 3 main sections. The left-side panel contains the JSON being inspected. The right top panel is the JSONata expression. The right bottom panel is the JSON output, based on the expression and JSON provided.

Basic Usage

The default page setup includes some JSON data to get started, and a sample expression as well.

...

Product

Price

Quantity

Bowler Hat

34.45

2

Trilby Hat

21.67

1

Bowler Hat

34.45

4

Cloak

107.99

1

Deconstruct expressions to see their behaviors

It can be helpful to deconstruct expressions to better understand how they work.

  1. In the example above, remove “$sum(“ from the start of the expression, and remove the last “)” from the end of it. You will notice the output changes significantly from a single value to an array of values.

    image-20240328-174637.pngImage Removed

    .

    image-20240328-175041.pngImage Added
  2. We now see expressed output for each product element.

  3. To understand specifically which items are being considered in the mathematical formula, remove that part of the expression. Remove “.(Price * Quantity)” from the expression and observe the output.

  4. It should now be apparent which elements the (Price * Quantity) operation is working against, and further, the values being calculated by the original $sum operation.

Square 9 Sample Setup

The default example provided is great for exploring basic functionality, but it’s not consistent with the JSON format provided by FTE. Let try working with sample output that matches the FTE response syntax.

  1. Clear the expression in the top right panel.

  2. Clear the JSON in the left panel.

Info

To clear the panels, simply select all (Ctrl+A) and hit the delete key.

With the stoeBrowse to the expression exercise sample data, and copy / paste it into the JSONata Exerciser’s JSON input panel (left side panel).