README

NAME

JSON::Path - Implementation of the JSONPath data structure query language

SYNOPSIS

use JSON::Path;

# Example data.
my $data = {
  kitchen => {
    drawers => [
      { knife => 'šŸ”Ŗ' },
      { glass => 'šŸ·' },
      { knife => 'šŸ—”ļø' },
    ]
  }
};

# A query
my $jp = JSON::Path.new('$.kitchen.drawers[*].knife');

# The first result
dd $jp.value($data);  # "šŸ”Ŗ"

# All results.
dd $jp.values($data); # ("šŸ”Ŗ", "šŸ—”ļø").Seq

# All paths where the results were found.
dd $jp.paths($data);  # ("\$.kitchen.drawers[0].knife",
                      #  "\$.kitchen.drawers[2].knife").Seq

# Interleaved paths and values.
dd $jp.paths-and-values($data);
# ("\$.kitchen.drawers[0].knife", "šŸ”Ŗ",
#  "\$.kitchen.drawers[2].knife", "šŸ—”ļø").Seq

DESCRIPTION

The JSONPath query language was designed for indexing into JSON documents. It plays the same role as XPath does for XML documents.

This module implements JSON::Path. However, it is not restricted to working on JSON input. In fact, it will happily work over any data structure made up of arrays and hashes.

Query Syntax Summary

The following syntax is supported:

A query that is not rooted from $ or specified using .. will be evaluated from the document root (that is, same as an explicit $ at the start).

AUTHORS

  • Jonathan Worthington

Source can be located at: https://github.com/raku-community-modules/JSON-Path . Comments and Pull Requests are welcome.

COPYRIGHT AND LICENSE

Copyright 2012 - 2024 Jonathan Worthington

Copyright 2024, 2025, 2026 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

JSON::Path v1.10

Implementation of the JSONPath data structure query language

Authors

  • Jonathan Worthington

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • JSON::Path

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.